arrayListOf

Common
JVM
JS
Native
1.1
fun <T> arrayListOf(): ArrayList<T>
(source)

Returns an empty new ArrayList.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val list = arrayListOf<Int>()
println("list.isEmpty() is ${list.isEmpty()}") // true

list.addAll(listOf(1, 2, 3))
println(list) // [1, 2, 3]
//sampleEnd
}
Common
JVM
JS
Native
1.0
fun <T> arrayListOf(vararg elements: T): ArrayList<T>
(source)

Returns a new ArrayList with the given elements.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val list = arrayListOf(1, 2, 3)
println(list) // [1, 2, 3]

list += listOf(4, 5)
println(list) // [1, 2, 3, 4, 5]
//sampleEnd
}