The **java.lang.Math.random()** returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.

int randomNumbersWithRange(int min, int max)
{
int range = (max - min) + 1;
return (int)(Math.random() * range) + min;
}

Output of **randomNumbersWithRange(1, 5)** 5 times:

2
4
2
1
3