Collections & Java

This Atom is Under Construction

This book doesn’t require Java knowledge. However, when you write code in Kotlin for the JVM, you must still be familiar with the Java standard collections library, because that’s what Kotlin uses under the hood.

The collections library is a set of classes and interfaces that implement collection data structures, such as lists, sets and maps. These data structures usually have clear and simple interfaces, but for speed may have complicated implementations.

This atom describes the basic structure of the Kotlin standard collections library along with caveats about using third-party Java libraries or working on mixed Kotlin and Java projects.

New languages typically create their own collections library from scratch. For example, Scala has its own collections library which in many ways surpasses the Java collections library, but also makes it more challenging to mix Scala and Java.

Kotlin’s collections library is intentionally not rewritten from scratch; instead, it consists of improvements atop the Java collections library. For example, when you create a mutable List, you’re actually using Java’s ArrayList:

End of sample. See AtomicKotlin.com for full early-access book.



Previous          Next

©2018 Mindview LLC. All Rights Reserved.