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 trialTrevyn Mikesell
1,075 PointsQuestion
There was nothing about nextInt in the video and I am having trouble figuring it out
1 Answer
Stone Preston
42,016 Pointshere is how you use nextInt:
first create a random object
Random rand = new Random();
then call the nextInt method on that random Object
int myInt = rand.nextInt();
you can pass a parameter to the nextInt method to specify an exclusive range
int myInt = rand.nextInt(20);
would produce a random number between 0 and 20 exclusively (so the highest number you could get would be 19)