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 trialjamar taylor
302 PointsCreate a String variable named intAsString. Convert the randomNumber integer to a String value and store it in the intAs
don't understand none of it ..
Random randomGenerator = new Random ();
int RandomNumber = randomGenerator.nextInt(10);
1 Answer
Gabriel Ward
20,222 PointsHi Jamar,
Random randomGenerator = new Random();
Here we are generating a new Random number object and storing it in a Random object called randomGenerator.
int RandomNumber = randomGenerator.nextInt(10);
getting a random number by calling the nextInt method on randomGenerator, which we know is an object of type Random. the parameter we are passing in the method is the upper bound of what the number can be. So in this case it can be between one and ten. Finally we are storing this random number into a variable called RandomNumber (this should probably be randomNumber) which is of type int.
The next thing to do would be to call ToString() on randomNumber and store it in a string variable.
string intAs = randomNumber.ToString();