Examveda

You would like to print each score on its own line with its cardinal position. Without using var or val, which method allows iteration with both the value and its position?
fun main() {
  val highScores = listOf(4000, 2000, 10200, 12000, 9030)
}

A. .withIndex()

B. .forEachIndexed()

C. .forEach()

D. .forIndexes()

Answer: Option A


This Question Belongs to Computer Science >> Kotlin Program

Join The Discussion

Related Questions on Kotlin Program

What is Kotlin?

A. A new version of Java.

B. A JavaScript framework.

C. A statically-typed programming language for the JVM, Android, and browser.

D. A database management system.