0
How do u get a random number in Kotlin
Using java.util.Random or any other method
6 Antworten
+ 7
fun main(args: Array<String>) {
val random = java.util.Random();
var test = "ABCDEFGH"
var num = random.nextInt(test.length);//(7)
println(num)
println(test[num])
}
+ 5
I have been extending the Kotlin course. This is my Random lesson.
https://www.sololearn.com/post/529872
+ 2
kotlin can use the java libraries.
+ 2
Just found out.
Thanks everyone for your help
+ 1
Just add the limit of the randomness you want it to reach
https://code.sololearn.com/c5Dt7z7w9M5c/?ref=app
+ 1
Rik Wittkopp isn't my answer nice
Check out the code