arrayListOf
Returns an empty new ArrayList.
Since Kotlin
1.1Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = arrayListOf<Int>()
println("list.isEmpty() is ${list.isEmpty()}") // true
list.addAll(listOf(1, 2, 3))
println(list) // [1, 2, 3]
//sampleEnd
}
Returns a new ArrayList with the given elements.
Since Kotlin
1.1Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = arrayListOf(1, 2, 3)
println(list) // [1, 2, 3]
list += listOf(4, 5)
println(list) // [1, 2, 3, 4, 5]
//sampleEnd
}
Returns an empty new ArrayList.
Since Kotlin
1.1Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = arrayListOf<Int>()
println("list.isEmpty() is ${list.isEmpty()}") // true
list.addAll(listOf(1, 2, 3))
println(list) // [1, 2, 3]
//sampleEnd
}
Returns a new ArrayList with the given elements.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val list = arrayListOf(1, 2, 3)
println(list) // [1, 2, 3]
list += listOf(4, 5)
println(list) // [1, 2, 3, 4, 5]
//sampleEnd
}