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 trialNelson Pierce
2,143 PointsTrouble with This section
I am having a hard time getting the Challenge 1-4 please help. (stage 2 first challenge task)
1 Answer
Ernest Grzybowski
Treehouse Project ReviewerI'll try to help you with the first challenge, and after that, you can let me know if you need extra help.
The first question reads:
Initialize a new Random variable called randomGenerator using the Random() constructor.
You are given:
Random randomGenerator;
The code that you are given already is "defining" a new variable named randomGenerator
and it is of type Random
. They now want you to "initialize" it using the Random class' constructor (i.e. Random()
). This means that you need to take your randomGenerator
variable that is already defined, and set it equal to a new Random
object.
Random randomGenerator = new Random();
This should successfully pass the code challenge. Doing this is one of the most basic and fundamental parts of Java. Defining and initializing variables. Take a look at Ben Jakubens blog posts regarding Java Basics.