Public class Test {public static void main(String[] args){Random rand = new Random(); for(int i=0; i<10; i++) { System.out.println(rand.nextInt(100) + 1); }} // Generate random values in interval [64,128] : rand.nextint (65)+ 64;Copy the code

Final formula:

//randNumber will be assigned to a random number in the range of MIN and MAX int randNumber =rand. NextInt (max-min + 1) + MIN;Copy the code