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 trialMUZ140073 Lionell Matambanadzo
12,509 Pointscode challenge .Initialize a new Random variable called randomGenerator using the Random() constructor.
Initialize a new Random variable called randomGenerator using the Random() constructor.
Random randomGenerator;
MUZ140073 Lionell Matambanadzo
12,509 Pointsthank you
MUZ140073 Lionell Matambanadzo
12,509 Pointsthank you
Dylan Merritt
15,682 PointsSo in the code that you posted, you have declared an instance of the Random class. This is basically telling the computer, "Hey, I'm going to use the Random class, and I'm going to name this usage of it randomGenerator." However, the computer doesn't quite know what that means. It knows you will be using the Random class, but it doesn't know what exactly what to do with that information. So what you say next is "randomGenerator is going to generate a random number." So your code should look like this:
Random randomGenerator = new Random();
Good luck.
1 Answer
Greg Schmidt
5,908 PointsThey are asking to create a new Random variable using the Random() constructor so:
Random randomGenerator = new Random();
Danial Goodwin
13,247 PointsDanial Goodwin
13,247 PointsDid you have any issues with this? What was the error you got when trying it?