liveBook · Manning

Kotlin standard library

As explained in Kotlin in Action, 2E

A library containing runtime definitions required by compiled Kotlin programs, including fundamental Kotlin classes and extensions to Java APIs.

The Kotlin standard library provides the runtime definitions and APIs that make ordinary Kotlin code practical. It includes fundamental types such as Int and String, collection types such as List, Map, and Sequence, and extensions to Java APIs. Functional collection operations let Kotlin combine concise lambdas with familiar object-oriented code. section 1.5.2 section 1.2.3

messages
   .filter { it.body.isNotBlank() && !it.isRead }
   .map(Message::sender)
   .distinct()
   .sortedBy(Sender::name)

A collection pipeline filters unread messages with nonblank bodies, extracts senders, removes duplicates, and sorts by sender name. section 1.2.3

Each operation expresses one transformation: filter keeps matching messages, map converts messages to senders, distinct removes repeated values, and sortedBy orders the result. Lambdas and member references keep the code compact without requiring manual traversal and aggregation. section 1.2.3 section 6.1

Use the library in two closely related ways:

  • Rely on fundamental Kotlin classes and extensions that compiled JVM programs need at runtime. section 1.5.2
  • Apply standard collection functions such as filter and map, customizing behavior with lambdas. section 6.1
  • Let Gradle or Maven manage Kotlin runtime and standard-library dependencies in typical mixed Kotlin and Java projects. section 1.5.2

How Kotlin in Action, 2E covers it

How deep it goes
Defines fundamental classes and collection operations, then demonstrates pipelines; it stops short of a complete API reference.
Examples
Demonstrates a message pipeline using filter, map, distinct, and sortedBy to find unique senders of unread messages.
What it assumes
Assumes basic Kotlin and collection familiarity while introducing functional operations through concrete examples.
What you can do after
Apply standard collection APIs to write concise, consistent transformations and package JVM applications with required Kotlin dependencies.
How it connects
Connects Kotlin types, collections, sequences, lambdas, member references, Java APIs, Gradle, Maven, and JVM compilation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kotlin in Action, 2E. The section links point to the parts of the book it draws on.