Skip to content
Learn Netverks

Lesson

Step 6/36 17% through track

hello-world-kotlin

Hello, World in Kotlin

Last reviewed Jun 1, 2026 Content v20260601
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Hello, World in Kotlin: the syntax, patterns, and safety habits you need before advancing in Kotlin.

Teams still ship Hello, World in Kotlin in Kotlin codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Hello, World in Kotlin in contexts like: Android apps, Spring services, and shared KMP modules.

Write Kotlin in main.kt with fun main(), click Run on server—the dev runner kotlinc compiles to a JVM jar and java runs it; use println for output (requires JDK + kotlinc; LEARNING_RUNNER_ENABLED=true). Also use fun main() and println; avoid Android imports in the sandbox.

When you can explain the previous lesson's ideas without copying starter code.

Every Kotlin program needs an entry point—top-level fun main(). Output uses println, similar to System.out.println in Java or print() in Python without requiring a class wrapper.

Minimal program

fun main() {
    println("Hello, World")
}

println writes a line to stdout. Semicolons are optional; expressions often omit them.

Compared to Java

Java requires public class Main matching the filename. Kotlin allows multiple functions in one file—the compiler generates a MainKt class for top-level main.

Important interview questions and answers

  1. Q: What prints text in Kotlin?
    A: println, print, and printf-style formatting with string templates.
  2. Q: Must every Kotlin file declare a class?
    A: No—top-level functions and properties are idiomatic.

Self-check

  1. Which function is the program entry point?
  2. What JVM class runs when you compile main.kt?

Tip: Top-level fun main() needs no class wrapper—unlike Java public class Main.

Interview prep

What prints text?

println, print, and string templates.

Entry point?

Top-level fun main().

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • println vs print?
  • Semicolons needed?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump