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 do not understand how to do the challenge

Random randomGenerator = new Random(); int randomNumber = randomGenerator.nextInt(facts.length); fact = facts[randomNumber];


2 Answers

Arturo Alviar
Arturo Alviar
15,739 Points

Use the number ten rather than facts.length.
The facts variable is not defined in the challenge.

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Bruce,

I commented the challenge a little:

Random randomGenerator;
// TASK 1
randomGenerator = new Random();

// TASK 2
// int randomNumber = randomGenerator.nextInt(); 
// here the generator will create a rundom number without a range

// TASK3
int randomNumber = randomGenerator.nextInt(10); 
// here the generator will create a rundom number between 0 an 9

String intAsString = Integer.toString(randomNumber);
// create a new String variable and convert the int "randomNumber" into a String using toString method


Thank you a lot i really appreciate the help.