Reputation: 59
How to output a random string from a given array of string or from a list in Kotlin
var arr = arrayOf("People", "Are", "Awesome")
Upvotes: 1
Views: 693
Reputation: 3850
You can use the random function: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/random.html
fun main() {
val arr = arrayOf("People", "Are", "Awesome")
println(arr.random())
}
Upvotes: 5