add
Adds the specified element to the end of this list.
Since Kotlin
1.0Return
true
because the list is always modified as the result of this operation.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.add('c') is ${list.add('c')}") // true
println(list) // [a, b, c, c]
//sampleEnd
}
Inserts an element into the list at the specified index.
All elements that had indices index .. index + size - 1
are shifted 1 position right.
If index is equal to size, element will be appended to this list.
Since Kotlin
1.0Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.add(1, 'c')
println(list) // [a, c, b, c]
list.add(4, 'a')
println(list) // [a, c, b, c, a]
// list.add(100500, 'a') // will fail with IndexOutOfBoundsException
//sampleEnd
}
Adds the specified element to the end of this list.
Since Kotlin
1.1Return
true
because the list is always modified as the result of this operation.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.add('c') is ${list.add('c')}") // true
println(list) // [a, b, c, c]
//sampleEnd
}
Inserts an element into the list at the specified index.
All elements that had indices index .. index + size - 1
are shifted 1 position right.
If index is equal to size, element will be appended to this list.
Since Kotlin
1.1Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.add(1, 'c')
println(list) // [a, c, b, c]
list.add(4, 'a')
println(list) // [a, c, b, c, a]
// list.add(100500, 'a') // will fail with IndexOutOfBoundsException
//sampleEnd
}
Adds the specified element to the end of this list.
Since Kotlin
1.0Return
true
because the list is always modified as the result of this operation.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.add('c') is ${list.add('c')}") // true
println(list) // [a, b, c, c]
//sampleEnd
}
Inserts an element into the list at the specified index.
All elements that had indices index .. index + size - 1
are shifted 1 position right.
If index is equal to size, element will be appended to this list.
Since Kotlin
1.0Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.add(1, 'c')
println(list) // [a, c, b, c]
list.add(4, 'a')
println(list) // [a, c, b, c, a]
// list.add(100500, 'a') // will fail with IndexOutOfBoundsException
//sampleEnd
}
Adds the specified element to the end of this list.
Since Kotlin
1.3Return
true
because the list is always modified as the result of this operation.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.add('c') is ${list.add('c')}") // true
println(list) // [a, b, c, c]
//sampleEnd
}
Inserts an element into the list at the specified index.
All elements that had indices index .. index + size - 1
are shifted 1 position right.
If index is equal to size, element will be appended to this list.
Since Kotlin
1.3Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.add(1, 'c')
println(list) // [a, c, b, c]
list.add(4, 'a')
println(list) // [a, c, b, c, a]
// list.add(100500, 'a') // will fail with IndexOutOfBoundsException
//sampleEnd
}
Adds the specified element to the end of this list.
Since Kotlin
1.8Return
true
because the list is always modified as the result of this operation.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.add('c') is ${list.add('c')}") // true
println(list) // [a, b, c, c]
//sampleEnd
}
Inserts an element into the list at the specified index.
All elements that had indices index .. index + size - 1
are shifted 1 position right.
If index is equal to size, element will be appended to this list.
Since Kotlin
1.8Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.add(1, 'c')
println(list) // [a, c, b, c]
list.add(4, 'a')
println(list) // [a, c, b, c, a]
// list.add(100500, 'a') // will fail with IndexOutOfBoundsException
//sampleEnd
}
Adds the specified element to the end of this list.
Since Kotlin
1.8Return
true
because the list is always modified as the result of this operation.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
println("list.add('c') is ${list.add('c')}") // true
println(list) // [a, b, c, c]
//sampleEnd
}
Inserts an element into the list at the specified index.
All elements that had indices index .. index + size - 1
are shifted 1 position right.
If index is equal to size, element will be appended to this list.
Since Kotlin
1.8Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.add(1, 'c')
println(list) // [a, c, b, c]
list.add(4, 'a')
println(list) // [a, c, b, c, a]
// list.add(100500, 'a') // will fail with IndexOutOfBoundsException
//sampleEnd
}