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!
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

Louie Jacques Harrison
Courses Plus Student 324 PointsStuck AGAIN!
Help!
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
intAsString = ;
3 Answers

Devin Scheu
66,191 PointsYour code should look like this:
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = randomNumber + "";

Nicolas Hampton
44,638 PointsWhat's going on here is that the code need the random number to be stored as a string, not an int, for some reason unknown to us in the code you've shown. An easy way to do this is to take a int value and add a space to the end of it. This looks like:
8 + ""
This will make the integer value into a string, so you can use it with methods and classes that require strings. If this helps, please rate it and let me know! Happy Coding!
Nicolas

ticksonwang
2,666 PointsOr the conventional ways would be by using the Integer.toString(int i) or String.valueOf(int i). in this case: String intAsString = Integer.toString(randomNumber); or String intAsString = String.valueOf(randomNumber);