elementAt
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this collection.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this list.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.1Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.8Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Returns an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this array.
Since Kotlin
1.8Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list.elementAt(0)) // 1
println(list.elementAt(2)) // 3
// list.elementAt(3) // will fail with IndexOutOfBoundsException
val emptyList = emptyList<Int>()
// emptyList.elementAt(0) // will fail with IndexOutOfBoundsException
//sampleEnd
}