how to generate a random number between a range in java code example Example: java random number generator in range int rand = ThreadLocalRandom.current().nextInt(x,y);