java generate random number between 1 and 100 code example
Example 1: random number in range java
(int)(Math.random() * ((max - min) + 1)) + min
Copy
Example 2: java random number between 100 and 999
int upperBound = 999;
int lowerBound = 100;
int number = lowerBound + (int)(Math.random() * ((upperBound - lowerBound) + 1));