Learn Kotlin

Concise, null-safe JVM language for Android, backends and multiplatform apps

26 lessons · 5 hours · 4 levels · covers Kotlin 2.2

Kotlin is a modern statically typed language from JetBrains that runs on the JVM, compiles to JavaScript and native code, and interoperates fully with Java. It is Google's preferred language for Android and widely used for server-side development with Spring and Ktor. Learning it gives you null safety, concise syntax, powerful functional features and coroutines for structured concurrency.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics9 lessons · 2 hours in total
2. PracticalUse it productively at work, with the usual idioms17 lessons · 3 hours in total
3. AdvancedThe less common features, performance and trade-offs23 lessons · 4 hours in total
4. ExpertInternals and the edge cases experts know26 lessons · 5 hours in total

The Kotlin tree

KotlinHello Kotlin: main and toolingHello Kotlin: main andtoolingval, var and basic typesval, var and basictypesStrings and templatesStrings and templatesif, when and loopsif, when and loopsFunctionsFunctionsNull safetyNull safetyLists, sets and mapsLists, sets and mapsClasses and propertiesClasses andpropertiesData classesData classesLambdas and higher-order functionsLambdas andhigher-order functi…Collection operationsCollection operationsInheritance and interfacesInheritance andinterfacesObjects and companion objectsObjects andcompanion objectsEnums and sealed hierarchiesEnums and sealedhierarchiesExtension functionsExtension functionsScope functions: let, apply, also, run, withScope functions: let,apply, also, run, withExceptions and error handlingExceptions and errorhandling
Essentials and Practical shown (17 of 26 lessons); the full list is below. Click a lesson to read it.

All 26 lessons, in order

Basics

  1. Hello Kotlin: main and tooling · Essentials · 8 min

    Write a main function, compile and run Kotlin code, and know where IntelliJ IDEA, Gradle and the REPL fit.

  2. val, var and basic types · Essentials · 10 min

    Declare read-only val and mutable var variables, rely on type inference, and use Kotlin's numeric, Boolean, Char and String types.

  3. Strings and templates · Essentials · 8 min

    Build strings with templates, raw multiline strings and common String functions.

  4. if, when and loops · Essentials · 10 min

    Use if and when as expressions, loop with for over ranges and collections, and use while.

  5. Null safety · Essentials · 12 min

    Use nullable types, safe calls, the Elvis operator, smart casts and !! to eliminate NullPointerExceptions.

Functions and lambdas

  1. Functions · Essentials · 10 min

    Declare functions with typed parameters, default and named arguments, single-expression bodies and varargs.

  2. Lambdas and higher-order functions · Practical · 12 min

    Pass functions as values with lambdas, function types, it, trailing lambda syntax and function references.

  3. Extension functions · Practical · 10 min

    Add functions and properties to existing types without inheritance, including nullable receivers.

  4. Scope functions: let, apply, also, run, with · Practical · 10 min

    Choose between let, run, with, apply and also by how they refer to the object and what they return.

  5. Exceptions and error handling · Practical · 10 min

    Throw and catch exceptions, use try as an expression, require/check preconditions, and model failures with Result.

Collections

  1. Lists, sets and maps · Essentials · 10 min

    Create read-only and mutable lists, sets and maps, and access, iterate and update them.

  2. Collection operations · Practical · 14 min

    Transform data with map, filter, groupBy, associate, fold, sortedBy, partition, zip and sequences.

Classes and objects

  1. Classes and properties · Essentials · 12 min

    Define classes with primary constructors, properties, init blocks, custom accessors and visibility modifiers.

  2. Data classes · Essentials · 10 min

    Model values with data classes that generate equals, hashCode, toString, copy and componentN functions.

  3. Inheritance and interfaces · Practical · 12 min

    Extend open classes, override members, write abstract classes and implement interfaces with default methods.

  4. Objects and companion objects · Practical · 10 min

    Create singletons with object declarations, class-level members with companion objects, and one-off objects with object expressions.

  5. Enums and sealed hierarchies · Practical · 12 min

    Model fixed sets of values with enum classes and closed type hierarchies with sealed classes and exhaustive when.

Advanced Kotlin

  1. Generics and variance · Advanced · 14 min

    Write generic classes and functions with bounds, declaration-site variance (in/out), star projections and reified type parameters.

  2. Delegation and delegated properties · Advanced · 12 min

    Implement interfaces by delegation with by, and reuse property logic with lazy, observable, map-backed and custom delegates.

  3. Java interoperability · Advanced · 12 min

    Call Java from Kotlin and Kotlin from Java: platform types, getters as properties, SAM conversions and @Jvm annotations.

  4. Inline functions and value classes · Expert · 14 min

    Know what inline, noinline and crossinline do to lambdas, and wrap values without allocation using value classes.

  5. Type-safe builders and DSLs · Expert · 14 min

    Build Kotlin DSLs with lambdas with receivers, extension function types and @DslMarker.

Coroutines

  1. Coroutines and suspend functions · Advanced · 15 min

    Write asynchronous code sequentially with suspend functions, launch, async/await and runBlocking.

  2. Structured concurrency and cancellation · Advanced · 15 min

    Understand coroutine scopes, parent-child jobs, dispatchers, withContext, cancellation and exception propagation.

  3. Flows · Advanced · 14 min

    Model asynchronous streams with Flow: builders, operators, collection, StateFlow and SharedFlow.

  4. How coroutines work under the hood · Expert · 15 min

    See how suspend functions compile to continuation-passing state machines and how dispatchers resume them.