Computer Science Canada Converting an Integer to a String? |
Author: | Delta [ Fri Jul 09, 2004 2:42 pm ] |
Post subject: | Converting an Integer to a String? |
Can anyone tell me how to convert an Integer to a String? I've tried this String converted; int num; converted = (int)num;... but I got this error > Incompatible Types converted = (String)num; ... but I got his error > Inconvertible Types and ya... I'm not sure what else to try... I've looked on http://java.sun.com but all I found were library breakdowns... and those don't help worth shit. |
Author: | Tony [ Fri Jul 09, 2004 3:00 pm ] | ||
Post subject: | |||
eh? ![]()
|
Author: | wtd [ Fri Jul 09, 2004 6:28 pm ] | ||||
Post subject: | |||||
![]() Alternately...
|
Author: | bugzpodder [ Fri Jul 09, 2004 7:50 pm ] | ||
Post subject: | |||
something like
probably also works |
Author: | wtd [ Fri Jul 09, 2004 7:57 pm ] | ||||
Post subject: | |||||
bugzpodder wrote: something like
probably also works Make that
And you're right, but that approach is also inefficient. |
Author: | Delta [ Sat Jul 24, 2004 8:20 am ] |
Post subject: | |
Very inefficient indeed... tisk tisk... lol anyways ya Tony your way works best compared to the other peoples which weren't really converting but anyways... ya :S... have a nice day |
Author: | rizzix [ Sun Jul 25, 2004 1:17 am ] |
Post subject: | |
actually that approach isin't "very" inefficient. it does the same thing: creates a Interger object and calls the toString() method. the only possibly additional thing it does is a concatenation with a "" empty string. now i'm pretty sure the javac optimizes this to simply a .toString() call. |