Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 19th, 2006, 8:22 PM   #1
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 597
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Int to String

In my program I need to change an int to a String. How can I do that?
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old May 19th, 2006, 8:32 PM   #2
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 929
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You can explicitly cast it to a String, or use the Integer.toString(int i) method.
titaniumdecoy is online now   Reply With Quote
Old May 19th, 2006, 8:33 PM   #3
gryfang
Programmer
 
gryfang's Avatar
 
Join Date: May 2006
Location: Ohio
Posts: 36
Rep Power: 0 gryfang is on a distinguished road
Send a message via AIM to gryfang
one integer to a string or a list oof integers?
it it's one then I think you need to nail down the exact requirements a little more concrete than that.
If it's an integer list then I would change it to characters using their acii representation.
__________________
--------------------
LOAD "*" ,8,1

God bless
- Gryfang

Last edited by gryfang; May 19th, 2006 at 8:35 PM. Reason: went from string to int not int to string
gryfang is offline   Reply With Quote
Old May 19th, 2006, 8:34 PM   #4
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 597
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
One int and titanium found the answer
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old May 19th, 2006, 8:38 PM   #5
NSchnarr
Newbie
 
Join Date: May 2006
Posts: 28
Rep Power: 0 NSchnarr is on a distinguished road
another easy trick way of doing it

int i = 5;
String str = "" + i;
NSchnarr is offline   Reply With Quote
Old May 19th, 2006, 8:51 PM   #6
gryfang
Programmer
 
gryfang's Avatar
 
Join Date: May 2006
Location: Ohio
Posts: 36
Rep Power: 0 gryfang is on a distinguished road
Send a message via AIM to gryfang
Glad you got your solution , sorry I went the wring direction with the conversion though .
__________________
--------------------
LOAD "*" ,8,1

God bless
- Gryfang
gryfang is offline   Reply With Quote
Old May 20th, 2006, 9:45 PM   #7
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 597
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
How do I turn a String into a Double?
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old May 20th, 2006, 10:02 PM   #8
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 597
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
The following code makes it an integer but i need it to be a double how do i do that?

String some number = "1";

somenumber = Integer.parseInt(num1);
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Old May 20th, 2006, 10:07 PM   #9
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3 Jimbo is on a distinguished road
Double.parseDouble(s)
Jimbo is offline   Reply With Quote
Old May 20th, 2006, 11:06 PM   #10
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 597
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Thanks
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC