I want to generate random number in a specific range. (Ex. Range Between 65 to 80)
I try as per below code, but it is not very use full. It also returns the value greater then max. value(greater then 80).
Random r = new Random();
int i1 = (r.nextInt(80) + 65);
How can I generate random number between a range?
val r = (0..10).random()
val randomNumber = (min..max).random()
wheremin
andmax
are the edges of the specified range. Refer Kotlin – Generate a Random Number in specific Range