Kotlin·Kotlin from syntax to a coroutine app

Setup and syntax

Run Kotlin and learn val, var, types and string templates.

Beginner 12 min read Lesson 1 of 300 Challenge included
What you will be able to do
  • Use val by default and var only when reassigning.
  • Use string templates with $name or ${expression}.
  • Prefer expression bodies for small functions.
  • Use IntelliJ IDEA or Android Studio.

In plain English

Kotlin runs on the JVM and compiles to JavaScript or native. val is an immutable binding, var is mutable. Type inference is strong, so annotate boundaries rather than every local.

Main.ktKotlin
fun main() {
    val name = "Ada"
    var count = 0
    count += 1
    println("Hello, $name! Count: $count")
}
Your turn

Use a string template

Easy

Print "Lesson: CSS" using a variable named title.

KOTLIN · starter
val title = "CSS"
Check your understanding before moving on.
Knowledge checkQuestion 1

What is the difference between val and var?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Null safety
Lesson 1 of 300 · 0% of course