Does java has toString function?

eg : txtamt.setText(toString(num));

But it doesn't work. Plz give me the right method.

Does java has toString function?

eg : txtamt.setText(toString(num));

But it doesn't work. Plz give me the right method.

Yes it has, but for Integer OBJECTS only and not for integer primitive data type.

You can wrap the integer into an Integer object,

but for your example

the easiest way, I think:

txtamt.setText(num+"");

would suffice.

alternatively, you could just use the following line;
txtamt.setText(String.valueOf(amt));

it'll display the integer in the text field or anything else you would use.
I just prefer it since its one line

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.