import java.util.Random;
Random rand = new Random();
// Obtain a number between [0 - 49].
int n = rand.nextInt(50);
// Add 1 to the result to get a number from the required range
// (i.e., [1 - 50]).
n += 1;
int random = (int) (Math.random()*(max-min+1)+min);
// Thread safe random number generator.
import java.util.concurrent.ThreadLocalRandom;
// Generate random integers
int val = ThreadLocalRandom.current().nextInt();
// Print random int
System.out.println("Random Integer: " + val);
Min + (int)(Math.random() * ((Max - Min) + 1))
import java.util.Random;
Random rand = new Random();
// Obtain a number between [0 - 49].
int n = rand.nextInt(50);
// Add 1 to the result to get a number from the required range
// (i.e., [1 - 50]).
n += 1;