0
Need help understanding random class in java
So I am currently trying to get hold off the random class and how its range works. Lets say that i have "Random rand = new Random(); and i want to figure out rand.nextInt(10) * 4; I get how to work with its range when using addition and subtraction (+, -) but I cant work around the multiplication and division. Can someone please explain it.
1 Odpowiedź
+ 6
rand.nextInt(10) returns a random integer from 0 to 9... now you are multiplying that number by 4.
min number is 0*4=0
max number is 9*4= 36
So you will get a number in range [0,36]
All possible outputs: 0,4,8,16,20,24,28,32,36