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