Hello World is an introductional program in every language. Usually, it is the best way to introduce to the language. It shows the basics of the language like its syntax, basic working, and functionalities, etc. Here I just show you Hello World in kotlin.
fun main(args: Array<String>) {
print("Hello World")
}
fun main (args: Array<String>) {…}
— This is amain
function, which is mandatory in every kotlin application. The compiler starts execution frommain
function. You can also call it as Entry Point of Every Kotlin Program. This function takes an array of string as arguments.fun
—fun
is a keyword, used to show that this is a function. In this case,main
is a function.print ()
— Theprint()
function is an inbuilt function that prints the value inside it. You can print values, calculation’s results, etc.println ()
— Theprintln()
function also works same as print() but it also prints a newline after the output. So if you have the next output then it will go to the next line. If nothing has to print it will print a blank line. Many legacy languages like C and C++ miss this function, in those languages we still walk with\n
, although it's really handy and useful.As you can guess, the semicolon is optional. The compiler is smart enough to understand that newline is the end of the statement.
So, guys, that’s it for Hello World. Feel free to ask for any queries.
Till then Keep Coding, Keep Loving.
Top comments (0)