Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App (retired 2014) Learning the Language Objects and Random Numbers

K W
K W
3,736 Points

LOST

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.

Edited your title. Could you please not swear on the forum.

Thanks

4 Answers

Hi 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.

Por 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.

Por 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
K W
3,736 Points

THANX SO MUCH FOR THE HELP EVERYBODY