Answers for "kotlin reverse list"

1

kotlin reverse list

val reversedList = oldList.reversed()

// Example
fun main() {
 	val list = listOf("A", "B", "C")
    println(list)
    val reversed = list.reversed()
    println(reversed)
}
Posted by: Guest on August-27-2021
0

how to invert list kotlin

import java.util.Collections
 
fun main() {
    val days: List<String> = listOf("Sunday", "Monday", "Friday")
 
    Collections.reverse(days)
 
    println(days)            // [Friday, Monday, Sunday]
}
Posted by: Guest on March-03-2021

Browse Popular Code Answers by Language