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
STAFF
Jennifer Nordell
Treehouse Staff

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
Jennifer Nordell
Treehouse Staff

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