java random number generator in range

Java
int rand = ThreadLocalRandom.current().nextInt(x,y);
Source

Also in Java: