Kotlin · Lesson 1 · On the house

Hello, Kotlin

fun main, println, top-level entry. Lesson 1 is free — on the house.

Lessons · Kotlin · Lesson 1 of 10 · On the house

Hello, Kotlin

fun main, println, top-level entry.

Illustration for Kotlin
Lesson 1 is on the house.

Kotlin programs on the JVM commonly start at a top-level fun main() or fun main(args: Array<String>). No class wrapper is required for a simple file.

println writes a line to standard output and adds a newline. print also exists but omits the trailing newline — idiomatic console demos use println.

Kotlin is case-sensitive: Println is not println. String literals need straight ASCII double quotes; curly “smart” quotes from a word processor break the compile.

Call syntax needs parentheses: println("hello"). Semicolons are optional and usually omitted.

Misses: writing public static void main (that is Java), using print when you meant a line break, or pasting curly quotes into the string.

hello

fun main() {
    println("hello")
}
Match this when you type.

Quiz

What is the usual top-level entry for a Kotlin JVM starter?

Quiz

Which call writes a line with a trailing newline?

Quiz

Is Kotlin case-sensitive?

Quiz

Which quotes belong in a Kotlin string literal?

Check

Match the still for: Hello, Kotlin.

Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.

Hello, Kotlin · Kotlin (free) — The Gold Standard