I'm new to kotlin, can any one help how to println(originalList[i]) out side the function

s-k, you have any mistakes here:

for (i in 1..1) ****(only 1 until 1 its give 1 time)

println(originalList[i]) ****(its is out of for statment {})

one ajustment suggest is :

fun main(args: Array<String>)

    val originalList = arrayOf("sathish", "ramesh", "kumar", "rajesh", "ram", "kom")

    for (i in 0..(originalList.size - 1)) {

       var t: Int = ((Math.random() * originalList.count()).toInt())

       println("Num $i : $t -> ${originalList[i]}")



Browse More Popular Posts

Leave a Comment