java random integer

Java
	(int)(Math.random() * ((max - min) + 1)) + min
Copyint rand = ThreadLocalRandom.current().nextInt(x,y);import java.util.Random;

class scratch{
    public static void main(String[] args) {
        Random rand = new Random();
        System.out.println( rand.nextInt(5) );
        //prints a random Int between 0 - 4 (including 0 & 4);
    }
}import java.util.Random();
Random <name> = new Random();
<variable> = <name>.nextInt(<excuslive top limit>);import java.util.Random;

Random rand = new Random();
int random_integer = rand.nextInt(upperbound-lowerbound) + lowerbound;import java.util.Random;
// import for random integer

Random random = new Random();
int randomInteger = random.nextInt(100); // Change this to create a new top bound
System.out.pritln(randomInteger + "Is the random number!");
Source

Also in Java: