Skip to content
Justice Tech School

The main Function

Every program starts in main. It may take args: Array<String>. Top level code and functions need no class.

Example
fun main(args: Array<String>) {
    println("Hello, Kotlin")
    println("args: ${args.size}")
}

Exercise

Entry function.

fun () {}

Quiz Test

Does Kotlin need a class for main?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.