|
-
Sep 22nd, 2006, 07:45 PM
#1
Thread Starter
Lively Member
convert integer to string
In java, how do you convert an integer to a string?
1 = '1'
Thanks
-
Sep 22nd, 2006, 10:16 PM
#2
Re: convert integer to string
Code:
int value=5;
String str=Integer.toString(value);
Last edited by ComputerJy; Sep 23rd, 2006 at 09:34 PM.
Reason: CornedBee is right
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 23rd, 2006, 12:31 AM
#3
PowerPoster
Re: convert integer to string
I alwys used following as ComputerJy used,
int int_value=100;
String string_value=Integer.toString(int_value);
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Sep 23rd, 2006, 07:19 PM
#4
Re: convert integer to string
> String str=""+5;
Not a good idea. This creates a temporary StringBuilder.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 23rd, 2006, 07:25 PM
#5
Re: convert integer to string
 Originally Posted by CornedBee
> String str=""+5;
Not a good idea. This creates a temporary StringBuilder.
Yeah I know, but there are people who still do it that way
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 23rd, 2006, 07:45 PM
#6
Frenzied Member
Re: convert integer to string
 Originally Posted by ComputerJy
Yeah I know, but there are people who still do it that way
Like me, but being lazy is my excuse.
-
Sep 23rd, 2006, 09:07 PM
#7
Re: convert integer to string
 Originally Posted by ComputerJy
Yeah I know, but there are people who still do it that way
All the more reason not to show new people this approach, or say that it's not good, no?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|