Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing an int into a string? 1

Status
Not open for further replies.

jisoo22

Programmer
Apr 30, 2001
277
US
Hello all,

This is a rather simple question. Does anyone know if there is a method for parsing an int into a string? I know you can do it the other way like:

String str = "9";
int num1 = Integer.parseInt(str);

But I need to convert an integer into a string. Any ideas?

Thanks,
Glen
 
if your "integer" is java.lang.Integer class
then

Integer a = new Integer(55);
String result = new String(a.intValue()+"");

if it is a primitive type then
int a = 5;
String result = new String(a+"");

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
ssipahi@yonbilgi.com
 
Use String static function :
public static String valueOf(int i)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top