how to set a range of numbers using math.random in java code example Example: java random number generator in range int rand = ThreadLocalRandom.current().nextInt(x,y);