Introduction to Kotlin

Kotlin is a modern, concise programming language that runs on the JVM and is Google's preferred language for Android development.

Learn Introduction to Kotlin in our free Kotlin course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick reference.

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.

By the end of this lesson you'll understand what Kotlin is and why it exists, how it improves on Java with conciseness and null safety, and you'll have written and run your own first Kotlin program that prints to the console.

What You'll Learn in This Lesson

1️⃣ What is Kotlin?

Kotlin was created by JetBrains (the company behind IntelliJ IDEA) and first appeared in 2011. It was designed to fix the everyday frustrations of writing Java while staying 100% compatible with it. It rests on a few key ideas:

Because of this, Kotlin powers a huge amount of modern software — especially Android apps and back-end servers. You'll start where every Kotlin developer starts: a tiny program that prints text. Read the worked example below first — every line is explained — then run it yourself.

2️⃣ Why Kotlin? Conciseness, Templates, and Null Safety

Two things make Kotlin feel different from Java straight away. First, type inference means you rarely write types — the compiler figures them out. Second, string templates let you embed values directly in text with $ , and a full expression with {'$ '} . Read the comments, predict the output, then check.

Notice how short that was: no type declarations, no + string concatenation, no semicolons. A val is a read-only variable (like final in Java), and the template syntax keeps the text readable. That conciseness is a big part of why developers love Kotlin.

Your turn. The program below works once you fill in the parts marked TODO . Follow the 👉 hints, then run it and compare with the expected output.

3️⃣ Running a Kotlin Program

Every standalone Kotlin program needs a main() function — that's where execution begins. To run a program on your own machine, save it in a file ending in .kt (for example Main.kt ), then compile and run it. The Kotlin Playground does this for you with one click.

No blanks this time — just a brief and an outline. Write it yourself, run it, and check your output against the example in the comments. This is exactly the kind of tiny program that builds real fluency.

📋 Quick Reference — Kotlin Basics

Practice quiz

What company created the Kotlin language?

  • Google
  • JetBrains
  • Oracle
  • Microsoft

Answer: JetBrains. Kotlin was created by JetBrains, the company behind IntelliJ IDEA.

Where does the execution of a standalone Kotlin program begin?

  • The first println
  • The start() method
  • The main() function
  • The top of the file

Answer: The main() function. Every runnable Kotlin program starts inside the main() function.

Which function writes a line of text to the console?

  • println
  • echo
  • console.log
  • print.line

Answer: println. println writes a line of text to standard output.

What file extension does a Kotlin source file use?

  • .kotlin
  • .kts only
  • .kt
  • .java

Answer: .kt. Kotlin source files end in .kt (scripts use .kts).

In a string template, how do you insert a plain variable named name?

  • {name}
  • %name%
  • $name
  • #name

Answer: $name. A leading $ inserts a variable's value: "Hello $name".

How do you embed a full expression inside a string template?

  • ${...}
  • $(...)
  • @{...}
  • <%...%>

Answer: ${...}. Wrap a full expression in ${...}, for example ${2026 - year}.

What keyword declares a read-only variable in Kotlin?

  • let
  • const
  • var
  • val

Answer: val. val declares a read-only variable, similar to final in Java.

On which platform does Kotlin most commonly run?

  • The JVM
  • Only Android hardware
  • The .NET CLR
  • A custom Kotlin VM

Answer: The JVM. Kotlin most commonly compiles to JVM bytecode and runs on the JVM.

How does Kotlin relate to Java?

  • It replaces the JVM entirely
  • It is fully interoperable with Java
  • It cannot call Java code
  • It only runs in browsers

Answer: It is fully interoperable with Java. Kotlin is fully interoperable with Java and shares the JVM.

Does Kotlin require a semicolon at the end of each line?

  • Yes, always
  • No, semicolons are optional
  • Only inside main()
  • Only for println calls

Answer: No, semicolons are optional. Kotlin does not require line-ending semicolons; they are optional.