Skip to content
iamnoobs

Beginner to advanced · 13 modules · 39 lessons

Learn Kotlin: Beginner to Advanced

Learn Kotlin from first principles through null safety, classes, collections, generics, coroutines, file handling, testing, HTTP APIs, and application design with short lessons, guided code, quizzes, checkpoints, and a capstone.

Who this is for: Beginners and developers who want to learn Kotlin for JVM applications, Android foundations, command-line tools, backend services, and modern application development.

Prerequisites: No prior Kotlin experience is required. Familiarity with files and running terminal commands is helpful. Examples primarily target Kotlin on the JVM; some dependency-based snippets are illustrative and may require Gradle dependencies. Examples are explanatory and are not compiled or executed on this website.

Meet Kotlin and the JVM

Your first Kotlin program

A Kotlin command-line application commonly starts in a top-level main function.

Kotlin is a statically typed language that can target the JVM and other platforms. For a JVM course, source files are commonly compiled with kotlinc or built with Gradle.

The main function is the conventional entry point for a command-line program. Kotlin's println function writes a value followed by a newline.

Guided example

Read through this example; code examples are for learning and are not executed on this site.

fun main() {
    println("Hello, Kotlin!")
}

Relevance quest · +10 XP

Which function is the usual entry point of a Kotlin command-line program?

Choose your answer

Mark this lesson complete when you are ready.

Module checkpoint: Meet Kotlin and the JVM

Practice this module by writing a small Kotlin program that uses meet kotlin and the jvm, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

After this module, you can:

  • Describe how Kotlin source code is compiled and run on the JVM.
  • Recognize main, package declarations, and imports.
  • Use compiler and build-tool feedback to fix simple problems.

Full curriculum

What you will learn

1. Meet Kotlin and the JVM

Beginner

Understand Kotlin's purpose, project structure, compiler, and basic syntax.

  1. Your first Kotlin program

    A Kotlin command-line application commonly starts in a top-level main function.

  2. Run and compile Kotlin

    The Kotlin compiler and build tools turn source code into runnable output.

  3. Comments, names, and basic syntax

    Kotlin uses case-sensitive names and supports line and block comments.

Module checkpoint: Practice this module by writing a small Kotlin program that uses meet kotlin and the jvm, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

2. Variables, Types, and Expressions

Beginner

Declare immutable and mutable values and work with Kotlin's core types.

  1. Immutable and mutable variables

    val prevents reassignment of a reference, while var permits reassignment.

  2. Numbers, Boolean, and characters

    Kotlin provides statically typed numeric and logical values.

  3. Strings and string templates

    String templates embed expressions directly in readable text.

Module checkpoint: Practice this module by writing a small Kotlin program that uses variables, types, and expressions, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

3. Operators, Conditions, and Ranges

Beginner

Build expressions and express conditional logic using Kotlin syntax.

  1. Arithmetic and comparison operators

    Operators calculate values and compare expressions.

  2. Conditions and if expressions

    In Kotlin, if can select and return a value.

  3. when branches and ranges

    when can replace long conditional chains, and ranges express intervals.

Module checkpoint: Practice this module by writing a small Kotlin program that uses operators, conditions, and ranges, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

4. Loops, Collections, and Iteration

Beginner

Repeat operations and process collections without off-by-one errors.

  1. for loops and ranges

    A for loop iterates over values supplied by a range or collection.

  2. while, do-while, and repeat

    Different loop forms suit condition-driven and count-driven repetition.

  3. Control loop flow

    break exits a loop and continue skips to the next iteration.

Module checkpoint: Practice this module by writing a small Kotlin program that uses loops, collections, and iteration, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

5. Functions, Lambdas, and Scope

Beginner

Create reusable functions and use default arguments, named arguments, and lambdas.

  1. Function parameters and return values

    Functions group reusable behavior behind a clear signature.

  2. Default and named arguments

    Default values reduce overloads, and named arguments clarify call sites.

  3. Lambdas and lexical scope

    A lambda is a function literal that can be stored or passed to another function.

Module checkpoint: Practice this module by writing a small Kotlin program that uses functions, lambdas, and scope, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

6. Null Safety and Type Modeling

Intermediate

Model optional values safely and represent alternatives with Kotlin's type system.

  1. Nullable and non-null types

    Kotlin encodes whether a variable may hold null in its type.

  2. Safe calls and the Elvis operator

    Safe calls and Elvis expressions provide concise nullable-value handling.

  3. Enums and sealed hierarchies

    Enums represent a fixed set of values; sealed types model a controlled set of variants.

Module checkpoint: Practice this module by writing a small Kotlin program that uses null safety and type modeling, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

7. Classes and Object-Oriented Kotlin

Intermediate

Create classes and data classes and understand properties, constructors, and inheritance.

  1. Classes and constructors

    A class defines a type, and a constructor initializes instances.

  2. Data classes and properties

    Data classes provide useful value-oriented methods for property-based models.

  3. Interfaces and inheritance

    Interfaces define contracts and open classes support controlled inheritance.

Module checkpoint: Practice this module by writing a small Kotlin program that uses classes and object-oriented kotlin, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

8. Collections and Functional Operations

Intermediate

Choose suitable collection types and process data with standard collection operations.

  1. Lists, sets, and maps

    Each collection type expresses a different way to organize values.

  2. Mutable collections and safe updates

    Mutable collections support updates while read-only APIs can limit accidental changes.

  3. Filter, map, and sorting

    Collection operations make data transformations explicit and composable.

Module checkpoint: Practice this module by writing a small Kotlin program that uses collections and functional operations, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

9. Generics, Extensions, and Delegation

Intermediate

Write reusable type-safe code and extend existing APIs without unnecessary inheritance.

  1. Generic functions and classes

    Generics allow reusable code to preserve type information.

  2. Extension functions and properties

    Extensions add callable syntax to a type without changing its source code.

  3. Composition and delegation

    Delegation forwards an interface implementation to another object.

Module checkpoint: Practice this module by writing a small Kotlin program that uses generics, extensions, and delegation, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

10. Exceptions, Files, and Serialization

Intermediate

Handle failures and work with files and structured data responsibly.

  1. Exceptions and failure paths

    try and catch handle exceptional failures at a boundary where recovery is possible.

  2. Reading and writing files

    File operations should specify their expected paths, encodings, and error behavior.

  3. JSON and serialization boundaries

    Structured formats need an explicit mapping between domain data and external representations.

Module checkpoint: Practice this module by writing a small Kotlin program that uses exceptions, files, and serialization, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

11. Coroutines and Concurrency

Advanced

Understand threads, structured concurrency, and coroutine-based asynchronous work.

  1. Threads and shared state

    Concurrency allows work to make progress during overlapping periods; parallelism means work executes at the same time.

  2. Suspend functions and coroutines

    Coroutines can suspend without blocking the underlying thread when using a compatible suspending operation.

  3. Structured concurrency and cancellation

    Structured concurrency ties child tasks to a defined lifecycle.

Module checkpoint: Practice this module by writing a small Kotlin program that uses coroutines and concurrency, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

12. Testing, Build Tools, and Project Structure

Advanced

Organize a Kotlin project for maintainability with automated checks and reliable builds.

  1. Packages, imports, and Gradle

    Packages organize source names, while Gradle manages repeatable JVM project builds.

  2. Unit testing with Kotlin

    Tests verify observable behavior for normal, boundary, and failure cases.

  3. Debugging and code quality

    Formatting, diagnostics, tests, and focused reviews improve reliability.

Module checkpoint: Practice this module by writing a small Kotlin program that uses testing, build tools, and project structure, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

13. HTTP APIs and Application Design

Advanced

Apply Kotlin skills to basic service design, configuration, and production readiness.

  1. HTTP clients and APIs

    HTTP defines requests and responses that application code should validate and handle explicitly.

  2. Input validation and configuration

    Validate untrusted input at boundaries and keep environment configuration separate from code.

  3. Release readiness and application boundaries

    Clear layers and repeatable checks make a small Kotlin application maintainable.

Module checkpoint: Practice this module by writing a small Kotlin program that uses http apis and application design, then test a normal case, an empty or boundary case, and one invalid or unexpected input. Explain why the result is correct before running the code.

Put it together

Kotlin capstone: Personal Study Tracker

Build a small study tracker that creates, lists, updates, filters, and completes study tasks. Model tasks with data classes, validate inputs, use collections, persist data to a file, and write tests. As an extension, expose a small HTTP API or use coroutines for concurrent operations where useful.

  1. 1Create a Kotlin/JVM project with Gradle and define a StudyTask data class with an ID, title, completion status, and optional category.
  2. 2Implement focused functions to add, list, complete, filter, and remove tasks; validate inputs and model missing tasks explicitly.
  3. 3Persist task data with a clear serialization strategy, handle file and parsing failures, and keep storage behavior separate from task rules.
  4. 4Add unit tests for empty collections, duplicate IDs, invalid titles, missing tasks, and persistence failures; run the full Gradle test task.
  5. 5Optionally expose operations through an HTTP API or add coroutine-based work with explicit cancellation and lifecycle rules; document build and run steps.

Progress is saved in this browser when local storage is available. You can continue without an account; changing browsers or clearing browser data may remove saved progress. Examples are not executed by the site.