Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialK W
3,736 PointsLOST
Declare a String variable named intAsString. Convert the randomNumber integer to a String value and store it in the intAsString variable. Hint: Use the toString() method of the Integer class.
String intAsString = integer.toString(randomNumber); <my answer I don't understand exactly what's being asked of me on this task or where to find the answer ive been stuck on this section for hours....any hints or help would be greatly appreciated.
4 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Kris,
You were so close. integer
should be capitalized.
I'll assume you have the correct previous code in place since you only posted the one line.
Cristian Rivera
2,192 PointsPor lo que veo quieres convertir un número (int) a una cadena (String) y esta misma almacenarla en la variable (intAsString).
Te dejo unas ejemplos básicos para convertir valores.
- int to String
int mInt = 5;
String mString = String.valueOf(mInt);
- String to int
String mString = "5";
int mInt = Integer.parseInt(mString);
Espero haberte aclarado o solucionado tu problema.
Cristian Rivera
2,192 PointsPor lo que veo quieres convertir un número (int) a una cadena (String) y esta misma almacenarla en la variable (intAsString).
Te dejo unas ejemplos básicos para convertir valores.
- int to String
int mInt = 5;
String mString = String.valueOf(mInt);
- String to int
String mString = "5";
int mInt = Integer.parseInt(mString);
Espero haberte aclarado o solucionado tu problema.
K W
3,736 PointsTHANX SO MUCH FOR THE HELP EVERYBODY
Adam Sackfield
Courses Plus Student 19,663 PointsAdam Sackfield
Courses Plus Student 19,663 PointsEdited your title. Could you please not swear on the forum.
Thanks