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 trial

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