This code uses the Random class to generate a random number up to 100.

You can change the 100 value to any interger you wish.

import java.util.*;
 
public class RandomNumber {
 
    public static void main(String[] args) {
 
        Random random = new Random();
        int rand = random.nextInt(100);
 
        System.out.println(rand);
 
    }
 
}