I don't it will either. In fact I know it won't.
Consider:
If you call nextInt(10), you get numbers 0, 1, ..., 9, so nextInt(10)+1 gives a number in the range 1, 2, ..., 10. Right?
If you call nextInt(25), you get numbers 0, 1, ..., 24, so nextInt(25)+1 gives a number in the range 1, 2, ..., 25. Right?
If you call nextInt(100), you get numbers 0, 1, ..., 99, so nextInt(100)+1 gives a number in the range 1, 2, ..., 100. Right?
Now here's the Biggie:
Suppose you want a function f(n) that returns a number in the range 1, 2, ..., n
Then inside the function:
- What argument do you use in calling nextInt?
- What do you do to the result returned from nextInt to obtain a value in the specified range?
Cheers!
Z