1
 2
 3
 4
 5
 6
 7
 8
 9
10
// randInt generates pseudo-random number 
// in the range [min...max] inclusive.
public static int randInt(int min, int max) 
{
    Random random = new Random();

    // nextInt is exclusive of the top value, 
    // so add 1 to make it inclusive
    return random.nextInt((max - min) + 1) + min;
}