Kotlin Tutorial
Master Kotlin from scratch with our comprehensive, interactive curriculum — 50 lessons from Beginner to Advanced.
Learn Kotlin from scratch — null safety, collections, lambdas, classes, data classes, coroutines and more — free interactive lessons (great for Android).
Part of the free Kotlin course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Start with Lesson 1 and build real skills step by step — at your own pace.
Lessons in this course
- Introduction to Kotlin — What Kotlin is, why Google picked it for Android, and your first program
- Variables (val & var) — Declare read-only and mutable variables with type inference
- Null Safety — Kotlin's signature feature — eliminate NullPointerExceptions at compile time
- Operators & Strings — Arithmetic, comparison, and logical operators plus string templates
- Control Flow & when — Make decisions with if expressions and the powerful when statement
- Functions — Define functions, return values, and write single-expression functions
- Default & Named Arguments — Reduce overloads with default parameter values and named arguments
- Collections (List, Set, Map) — Store groups of data with read-only and mutable collections
- Lambdas & Higher-Order Functions — Pass functions as values and write concise lambda expressions
- Collection Operations (map, filter, fold) — Transform and aggregate data with Kotlin's rich functional API
- Classes & Constructors — Model real-world things with classes, primary and secondary constructors
- Properties — Custom getters and setters, lateinit, and lazy properties
- Data Classes — Get equals, hashCode, toString, and copy for free with data classes
- Inheritance & Interfaces — Build class hierarchies with open classes, abstract classes, and interfaces
- Sealed Classes & Enums — Model restricted type hierarchies with sealed classes and enums
- Generics — Write reusable, type-safe code with generic classes and functions
- Extension Functions — Add new functions to existing types without inheritance
- Scope Functions (let, run, apply, also, with) — Write fluent, expressive code with Kotlin's five scope functions
- Coroutines Intro — Write asynchronous, non-blocking code with suspend functions
- Exception Handling — Handle errors gracefully with try/catch and custom exceptions
- Objects & Companion Objects — Singletons with object and static-like members with companion objects
- Control Flow (if, for, while) — if as an expression, for over ranges/collections, while, and labels
- Ranges & Progressions — 1..10, until, downTo, step, and in/!in membership checks
- Strings & String Templates — Interpolation, multiline raw strings, and the everyday string methods
- Arrays — arrayOf, IntArray, indexing and iterating — and how arrays differ from List
- Type Checks & Smart Casts (is, as) — is/!is, smart casts, and safe casting with as?
- Visibility Modifiers — public, private, protected and internal — and proper encapsulation
- Destructuring Declarations — Unpack pairs, data classes and map entries with componentN
- lateinit & lazy — Initialize non-null properties later, or compute them once on first access
- Checkpoint: Kotlin Basics — Combine ranges, strings, arrays and destructuring in a build — then a quiz
- Higher-Order Functions & Function Types — Pass and return functions, function references, and trailing lambdas
- Inline Functions & reified — Avoid lambda allocation and access generic types at runtime with reified
- Sequences (Lazy Collections) — Process data lazily for long operation chains and large data sets
- Interfaces & Abstract Classes — Default methods, interface properties, and interface vs abstract class
- Object Expressions & Declarations — Singletons with object, and anonymous objects for inline implementations
- Delegation & Delegated Properties (by) — Class delegation and delegated properties like lazy, observable, and by map
- Coroutine Scope, Context & Dispatchers — launch vs async, Dispatchers, withContext, and structured concurrency
- Flow & Channels — Cold asynchronous streams with flow and operators, plus Channel basics
- Checkpoint: Functions & OOP — Combine interfaces, objects and a function pipeline in a build — then a quiz
- Annotations & Reflection — Declare and read annotations, and inspect classes at runtime with ::class
- Operator Overloading — Give your types +, [], and comparison with operator functions
- Type Aliases & Value Classes — Add zero-overhead type safety with @JvmInline value classes
- Generic Variance (in / out) — Understand covariance (out), contravariance (in), and star projection
- Building DSLs (Lambdas with Receiver) — Create expressive builder DSLs with function types that have a receiver
- Result & runCatching — Handle failures without exceptions using Result, getOrElse, and fold
- Advanced Collections (groupBy, fold, windowed) — Group, aggregate, chunk, and zip collections like a pro
- Testing in Kotlin (JUnit & kotlin.test) — Write tests with assertEquals, assertFailsWith, and backtick names
- Java Interop — Call Java from Kotlin and Kotlin from Java with @Jvm annotations
- Checkpoint: Idiomatic Kotlin — Combine a value class, operator overload and a DSL in a build — then a quiz
- Capstone: A CLI App — Combine everything to build a complete command-line task manager
- Jetpack Compose Basics — Declarative UI with @Composable functions, Text, Button, Column and Row
- State & Recomposition in Compose — remember, mutableStateOf, state hoisting and recomposition
- Compose Layouts, Modifiers & Lists — Modifier chains, Box/Column/Row and LazyColumn/LazyRow
- Navigation in Compose — NavController, NavHost, routes and passing arguments
- Android Fundamentals: Activities & Lifecycle — Activities, the lifecycle, ViewModel and viewModelScope
- Serialization with kotlinx.serialization — @Serializable, Json.encodeToString/decodeFromString and @SerialName
- Networking with Retrofit — Retrofit interfaces, @GET/@POST, suspend functions and Ktor
- Kotlin Multiplatform Intro — Share code across platforms with expect/actual and commonMain
- Local Persistence with Room — Entities, DAOs and reactive Flow queries over SQLite with the Room library
- Dependency Injection with Hilt — Wire dependencies with Hilt modules, scopes and @Inject
- Gradle & the Kotlin Build System — build.gradle.kts, plugins, version catalogs and the Android Gradle Plugin
- Coroutine Exceptions & Cancellation — Handle failures and cancel cooperatively with SupervisorJob and handlers
- KSP & Annotation Processing — Compile-time codegen with Kotlin Symbol Processing — the engine behind Room and Hilt