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

not sure how to do last part of challenge

i can't figure out this last part of this challenge, please help

RandomTest.java
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);

2 Answers

Chase Marchione
Chase Marchione
155,055 Points

Hi Steve,

We want to declare and initialize a string named intAsString, and we know that we want it to hold the value of randomNumber converted to String. The video shows a way in which you can convert that value to String: by concatenating an empty string to the value. Thus:

String intAsString = randomNumber + "";

Hope this helps!

David Anton
PLUS
David Anton
Courses Plus Student 30,936 Points
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString  = Integer.toString(randomNumber);