Kotlin Hello World Program

In this tutorial we will make Kotlin hello world program.

When we start learning any new programming language, hello world is the very first program that we mostly make. So below I have shared the program along with its explanation.

There are various options for running kotlin programs. You can use kotlin compiler with command line or IDEs like IntelliJ and Eclipse.

Here I am using Eclipse IDE for making and running the programs. If you don’t know how to configure Eclipse to run Kotlin programs then follow below link to read the tutorial.

Also Read: How to Run Kotlin Program in Eclipse IDE

Kotlin Hello World Program

fun main(args: Array<String>){
	println("Hello World")
}

Output

Hello World

Explanation

The extension of kotlin program is .kt.

fun main(args: Array<String>){ }

In above program we first written main() function that takes string type array as an argument. In kotlin we can define a function using fun keyword. We will learn more about functions in later tutorials.

Every kotlin program must have main() function because it is the entry point from where program execution starts.

println(“Hello World”)

For displaying a message on console or output screen we simply write it in double quotes inside println() function.

If you are already familiar with Java language then you may observe that most of the code in Kotlin looks similar to Java. Actually internally Kotlin uses Java libraries and functions. And behind the scenes after compilation of kotlin program it is converted into .class file. As kotlin programs run on JVM so this .class file is used as input for JVM.

Comment below if you have any queries regarding above kotlin hello world program.

Leave a Comment

Your email address will not be published. Required fields are marked *