DEV Community

Cover image for Hello World in Kotlin
Jay Tillu
Jay Tillu

Posted on • Edited 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.

Follow me for more such content

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay