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 trialMichael Sander
569 Pointsi 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];
Random randomGenerator = New random ();
Int randomNumber = randomGenerator.nextInt ();
String Point = Points[randomNumber];
1 Answer
Jennifer Nordell
Treehouse TeacherHi 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!
Michael Sander
569 PointsMichael Sander
569 Pointsthank 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
Treehouse TeacherJennifer Nordell
Treehouse TeacherThen 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
569 PointsMichael Sander
569 Pointsthank you for your help