You can use below. Both start and end will be inclusive.
val start = 20
val end = 30
val rnd = new scala.util.Random
start + rnd.nextInt( (end - start) + 1 )
In your case
val r = new scala.util.Random
val r1 = 20 + r.nextInt(( 30 - 20) + 1)
You can use below. Both start and end will be inclusive.
val start = 20
val end = 30
val rnd = new scala.util.Random
start + rnd.nextInt( (end - start) + 1 )
In your case
val r = new scala.util.Random
val r1 = 20 + r.nextInt(( 30 - 20) + 1)