Kotlin Syntax

Kotlin syntax is compact and expression-oriented. The language prefers readability, explicit types when needed, and fewer special cases than older JVM languages.

Declarations

val language = "Kotlin"
var count = 1
println("$language count = $count")

Expressions

Many Kotlin constructs are expressions. That means they produce values instead of only performing actions.

Program shape

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

Syntax rules

  • Use val for values that should not change.
  • Use var only when reassignment is necessary.
  • Prefer small functions and explicit names.

Practice

  1. Write one main function that prints two lines.
  2. Change one var to val and explain the effect.
  3. Write one note about why Kotlin feels cleaner than Java in small programs.