Skip to content

The Main Function

Every Kotlin program must have a function called main. This function is the entry point to the Kotlin program - the section of code that is first run.

A simple example of a main function:

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

Notes:

  • The keyword fun indicates that this is a function
  • main is the name of the function
  • The empty brackets, (), indicate that this function requires no data (no parameters)
  • The braces, or 'curly brackets', {...} define the block of code for the function