List Creation in Kotlin

Level 277 keystrokes

Creates a read-only list and prints each element with a for loop.

Kotlin code

// listOf creates a read-only list of three strings
1val fruits = listOf("apple", "banana", "cherry")
// f takes each element in order; each is printed on its own line
2for (f in fruits) println(f)

Output

apple
banana
cherry
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Kotlin code and how often they appear.

  • "× 6
  • (× 3
  • )× 3
  • ,× 2
  • =× 1

More Kotlin examples at level 2

← Kotlin typing practice