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!
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
Declan Smith453 Points
I am totally stuck on this challenge task to 'Initialize a new random generator' help?
Ben JakubenTreehouse Teacher
You're halfway there! The two words you have so far declare the variable. You've given it a name and set its type.
Next, you need to initialize it by essentially putting something into that variable. It's currently empty. We usually put things into variables by setting them equal to something. In this case, you want a new Random object, so you use the
new keyword and then the Random class contructor, which is just the name followed by some empty parentheses.
Without giving you the complete answers, here are the parts you need to stick between
randomGenerator and the semicolon:
= new Random()