What does “fun main (args: <Arrays> Strings)” mean in Kotlin? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What does “fun main (args: <Arrays> Strings)” mean in Kotlin?

I see it every time at the beginning of every Kotlin Code Playground, could anyone explain why it's there or why a Kotlin code won't run without it?

30th Dec 2021, 5:57 PM
roboto codes
roboto codes - avatar
2 Answers
+ 2
Just to be clear though "no program will run without it" refers to if you are building a program which is meant to be started from that application. So if your learning Kotlin to make android apps you won't have the fun main because that's not where the program starts. In that case you are mearly buildings functions to use in an Android app. Other languages also have the ability to "bootstrap" to other languages and utilize their functions thus main would not be looked for.
30th Dec 2021, 7:01 PM
William Owens
William Owens - avatar
+ 1
This is the main function. The main function is the start point for every Kotlin program / application. No program will run w/o this function.
30th Dec 2021, 6:07 PM
Coding Cat
Coding Cat - avatar