main function in Kotlin

First things first, Kotlin supports both procedural programming and object oriented programming. If you have worked with some of the procedural languages, you may know that main() is the entry point to a program. Similarly, for Kotlin language as well, main() function (or method) in Kotlin file is the entry point to a Kotlin program. And you can write a class along with the main function in your Kotlin file.

In this section, we shall see a pictorial representation of the Kotlin file with main function, a data class and some helper functions.

main function in Kotlin - Kotlin Tutorial - www.tutorialkart.com

Kotlin Program with main function

An example Kotlin file, KotlinMainFunctionExample.kt is given below to demonstrate the main() function in Kotlin Program.

Output :

Refer wiki page for additional information.

Conclusion :

main() function is an entry point to Kotlin program like in most of the procedural programming languages.