typestar

Language basics

27 steps in 9 sets of Kotlin.

Kotlin is JetBrains' pragmatic answer to Java: a statically typed language for the JVM (and beyond) that keeps the platform and drops the ceremony. Since Google made it the preferred language for Android in 2019 it has become the default way tens of thousands of teams write for the phone in your pocket, while Spring and server-side shops adopted it for the same reason the IDE company built it — less boilerplate, null safety in the type system, and full interop with every Java library ever shipped.

This tour covers the core in typing-sized pieces: val and var, string templates, if and when as expressions, ranges, functions with defaults and named arguments, lambdas and collection chains, data classes and sealed hierarchies, the null-safety operators, scope functions, destructuring, operator and infix functions, generics, and delegation with by. The Encore is three complete programs — a word-frequency chart, a grade report, and a temperature summary — each one exercising what the sets taught.

Start this tour

Values

Control flow

  • if is an expressionKotlin has no ternary because if itself returns a value.
  • whenThe switch that matches ranges, lists of values, and bare conditions.
  • Ranges and loopsRanges are values, and for iterates anything that provides one.

Functions

Collections

Classes & objects

Null safety

Idioms

Generics & delegation

Encore

  • word_freq.ktA word-frequency table from a split, a tally map, and a two-key sort.
  • grade_report.ktReport cards from a data class roster, a when ladder, and format strings.
  • temp_stats.ktA week of temperatures: extremes, mean, a bar chart, and overnight swings.

The other Kotlin tours