Use nextInt(int n) of java.util.Random.