The main() Function
Every application requires an entry point where program execution is started. In most languages, including Kotlin, this is called the
Kotlin also allows writing script files (
.ktsfile ending) which don’t require an explicit
mainfunction, similar to Bash or Python scripts. When talking about an “application” above, such scripts are excluded.
In fact, even the code listings here on Educative require a
main function, although you have not seen one yet. Up until this point, a
main function was always hidden in code surrounding the code you saw in the listings. This is what enabled the code examples to run.
main function in Kotlin is simple: