DEV Community

Cover image for Hello World in Kotlin
Jay Tillu😎
Jay Tillu😎

Posted on • Updated on

Hello World in Kotlin

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")
}
Enter fullscreen mode Exit fullscreen mode
  • fun main (args: Array<String>) {…} — This is a main function, which is mandatory in every kotlin application. The compiler starts execution from main function. You can also call it as Entry Point of Every Kotlin Program. This function takes an array of string as arguments.

  • funfun is a keyword, used to show that this is a function. In this case, main is a function.

  • print () — The print() function is an inbuilt function that prints the value inside it. You can print values, calculation’s results, etc.

  • println () — The println() 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.

Jai Hind, Vande Mataram 🇮🇳

Wanna get in touch with me? Here are links. I’ll love to become your friend. 😊

Top comments (0)