KotlinListlistOf

Returns a new read-only list of given elements.

Syntax

listOf(vararg elements)

Example

Enter values below to update the example in real time.

val
fruits
listOf
println
size
apple
val fruits = listOf("apple", "banana", "cherry")
println(fruits.size)    // 3
println(fruits[0])      // apple