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 Basic Android Programming Using the Random Class

I can't make the last code challenge, i don't understand

I don't understand the question about making a string

RandomTest.java
Random randomGenerator = new Random ();
int randomNumber = randomGenerator.nextInt(10);
String[] {};

1 Answer

Jennifer Leap
Jennifer Leap
21,702 Points

The randomNumber variable is currently being stored as a integer. The question asks that it be converted to a String instead. There are a number of ways to do this. As per the video, you could simply add an empty String to the integer, which will convert it to a String, like this:

String intAsString = randomNumber + "";

Another solution is:

String intAsString = Integer.toString(randomNumber);

[mod edit-changed comment to answer]

Thanks a lot!