Course

Kotlin from the ground up

The modern language on the Java virtual machine

  • Beginner
  • 12 chapters
  • 200 min read

Learn Kotlin by running it: values and types, string templates, if and when as expressions, ranges and loops, functions with defaults and named arguments, lists, lambdas and the calls that replace most loops, maps, null safety, classes and data classes, and a sales report that uses the whole course at once.

What You'll Learn

  • Write and run a Kotlin program, and know what the compiler expects of it
  • Hold values in val and var, and tell whole numbers from decimals
  • Build text with string templates, and drop an expression into a string
  • Choose between values with if, and between many cases with when
  • Repeat work with ranges, until, step, downTo, and while
  • Write functions with return values, default arguments and named arguments
  • Keep several values in a list, and read them by position or by name
  • Replace loops with map, filter, sumOf, count and sortedBy
  • Store lookups in a map, and handle a key that is not there
  • Handle a value that may be missing with safe calls and fallbacks
  • Model records with classes, constructors and data classes, and copy them
  • Assemble a sales report with an interface, records and list transformations

Prerequisites

  • No programming experience needed — this course starts at the first line
  • Any other language you know will make the early chapters quick

Course Content

  1. 01
    Your first Kotlin

    What Kotlin is, the main function every program begins at, println and print, and output you can read one line at a time.

    Beginner · 14 min read

    Not started
  2. 02
    Values and types

    Val and var, the handful of types you meet first, whole numbers against decimals, and converting between them on purpose.

    Beginner · 15 min read

    Not started
  3. 03
    Text and string templates

    Building text with templates, dropping an expression into a string with braces, and the everyday string names worth knowing.

    Beginner · 15 min read

    Not started
  4. 04
    Decisions with if and when

    Comparing values, choosing between two paths, and treating if and when as expressions that produce a value instead of only running code.

    Beginner · 15 min read

    Not started
  5. 05
    Ranges and loops

    Counting with ranges, the until, step and downTo that adjust them, looping over a list of values, and the while loop for when the count is unknown.

    Intermediate · 16 min read

    Not started
  6. 06
    Functions

    Naming a piece of work, giving it inputs and an answer, letting callers leave out arguments, and passing arguments by name so the call explains itself.

    Intermediate · 17 min read

    Not started
  7. 07
    Lists

    Holding several values in order, reading them by position, walking them with a loop, and the difference between listOf and mutableListOf.

    Intermediate · 16 min read

    Not started
  8. 08
    Lambdas and list work

    Passing a small function into a list call, the single input named it, and the handful of calls that replace most loops you would otherwise write.

    Intermediate · 18 min read

    Not started
  9. 09
    Key and value maps

    Looking a value up by name instead of by position, what a missing key gives back, walking the pairs, and counting with a mutable map.

    Advanced · 17 min read

    Not started
  10. 10
    Null safety

    A value that may be missing, the question mark that says so in the type, the safe call and the fallback, and the double bang you should reach for last.

    Advanced · 18 min read

    Not started
  11. 11
    Classes and data classes

    Grouping values with the behaviour that belongs to them, constructors that also declare properties, and the data class whose equals, text form and copy are written for you.

    Advanced · 19 min read

    Not started
  12. 12
    Putting it together: a sales report

    A capstone that uses the whole course once: an interface that promises a total, records as data classes, one transformation per question, and a report printed at the end.

    Advanced · 20 min read

    Not started