Kotlin Cheat Sheet

This section documents Kotlin 2.4.x on the JVM, as published at kotlinlang.org, which is the reference these pages are written and verified against.

This content was generated with the assistance of AI and should be verified against kotlinlang.org before being relied on in production.

This section’s bibliography lists the reference material consulted while preparing these pages.

A single-page, colour-coded summary of the Kotlin essentials — types and val/var, string templates, ranges, control flow as expressions, functions with default/named arguments, classes and data class, inheritance and delegation, sealed classes and enums, objects and companion objects, extension and scope functions, lambdas and inline, generics and variance, null safety (?./?:/!!/as?), equality and operator overloading, collections and sequences, exceptions and Result, coroutines, coroutine context/cancellation, flows, and Android/tooling one-liners — handy for quick memorization or as a printable desk reference.

For the full explanation, every option, and additional examples, see the dedicated pages:

Getting started — Getting Started and Kotlin and the JVM.

Error handling — Exceptions and Error Handling.

Kotlin on Android and tooling — Kotlin for Android, Build and Tooling, and Testing.