Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App with Java Basic Android Programming Using the Random Class

Michael Sander
Michael Sander
569 Points

i can't pass the random test.java

i didn't know where is the mistake. i just write the same way like in the video.

Random randomGenerator = New Random (); Int rendomNumber = randomGenerator.nextInt (); String Point = Points[randomNumber];

RandomTest.java
Random randomGenerator = New random ();
Int randomNumber = randomGenerator.nextInt ();
String Point = Points[randomNumber];

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I'm not sure which step you're working on, but Step 1 of the challenge requires exactly one line of code. The first line of your code will not pass Step 1. When we're creating an instance of a class we use the new keyword, but you've typed New. Also, the class we're making an instance of is Random(), but you've typed random(). Remember, just about everything in programming is case-sensitive. You may not arbitrarily pick the capitalization and expect it to work.

Hope this helps! :sparkles:

Michael Sander
Michael Sander
569 Points

thank you for the answer. but i already tried:

Random randomGenerator = New Random (); Random randomGenerator = New random (); Random randomGenerator = new Random (); Random randomGenerator = new random (); all said error. i also tried no space after new random();

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Then I suggest you restart the challenge and try again because the 3rd one should have been correct with the caveat that there doesn't need to be a space between Random and the parentheses. Here is my line of code that passes Step 1. Yes, I've tested it.

Random randomGenerator = new Random();

Only one of those 4 you posted should have been correct, but there may have been a spelling error along the way.

Michael Sander
Michael Sander
569 Points

thank you for your help