Collection types in Kotlin

One of the main Kotlin goals is Java interoperability. So it's no wonder that Kotlin collections are interoperable with Java. When you specify that your functions receives List<T>, it is actually the same Java List<T> you're familiar with.

But Kotlin differentiates between mutable and immutable collections. The listOf() function is delegated to Arrays.asList(), and produces an immutable list, while mutableListOf() simply calls ArrayList().

On top of data, Kotlin collection has many useful extension methods, which we'll discuss later.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.178.9