Kotlin List.size
The Kotlin List.size property returns the size of the list.
Syntax
List.size
Example 1: Get the size of given list
In this example, we find the size of a given list of strings.
- Given list with some values in list1.
- Get the size of the list using size property on the list.
- You may print the list size to output.
Program
fun main(args: Array<String>) {
val list1 = listOf("a", "p", "p", "l", "e")
val listSize = list1.size
print(listSize)
}
Output
5