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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strings

Status
Not open for further replies.

robmif76

Programmer
Feb 1, 2003
10
0
0
GB
Any idea of a quick way to put the value of an integer into a string?

Cheers

Rob
 
Code:
int myNumber = 26;
String s = new String( "" + 26);
System.out.println( s);

[sub]1010100 1000111 1001001 1000110 [/sub]
-pete
 
Simply..
int i=9;
String s = i+"";

will do, no need to "new" it...
 
Here's another way:

int i = 9;
String s = String.valueOf( i );

Are you sorry you asked yet? "When you have eliminated the impossible, whatever remains, however
improbable, must be the truth." ~ Arthur Conan Doyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top