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

I can't get past this challenge!

It is telling me to convert the random number into a string and store it under a variable named intAsString but I have no clue how to do this!!!

1 Answer

Stone Preston
Stone Preston
42,016 Points

you need to create a new string variable. you can create a string like so:

String someString = "some string";

the challenge tells you it needs to be named intAsString and you need to use the toString method of the integer class to convert your random integer to a string. you can call that method like so:

Integer.toString(someInt)

where someInt is the integer variable you want to convert to a string. Putting that all together yields

String intAsString = Integer.toString(randomInt);

your random number variable may be named something different, in that above example I assumed it was named randomInt