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

help i dont now whathappend

help with this i use the keyword

RandomTest.java
Random randomGenerator = New Random ();
int randomNumber = randomGenerator.nextInt(facts.length);
fact = facts [randomNumber];

2 Answers

Jason Wiram
Jason Wiram
42,762 Points

Challenge one: Don't do more than the challenge asks. Your first line is close. "New" should not be capitalized though. I would also advise not adding a space between your class/object and method - example: Random().

Two: Your randomNumber variable should be created using nextInt(). "Facts" from the videos has nothing to do with this challenge.

Three: When limiting the range of your randomNumber, use a number (not a variable that doesn't exist in this challenge).

Four: Create a string named as required in the instructions and use string concatenation (like in the lessons) to convert your number to as string.

Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt(10);
String intAsString = randomNumber + "";
james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

just do exactly what the challenge asks. this code is close but not exactly right. firstly, the keyword is new, not New. also, there is no reference to anything called facts in the challenge.