kotlin Random()
snippet in kotlin

kotlin random number

user5329

val randomNumber = (100..200).random()

random class in kotlin

user8875

import kotlin.random.Random
 
fun rand(start: Int, end: Int): Int {
    require(start <= end) { "Illegal Argument" }
    val rand = Random(System.nanoTime())
    return (start..end).random(rand)
}
 
fun main() {
    val start = 5
    val end = 9
 
    for (i in 1..5) println(rand(start, end))
}

kotlin Random()

user4689

val rnds = (0..10).random() // generated random from 1 to 9 included