In this tutorial you will learn about the Kotlin Hello World and its application with practical example.
Creating Kotlin Hello World Program
The “Hello world!” program is a simplest program that will display some text on the screen. The “Hello world!” program is a simple yet complete program for beginners that illustrates the basic syntax of any programming language. The “Hello world!” program gives you a way to test systems and programming environment.
This tutorial will guide you through writing a basic “Hello, World” program in Kotlin.
Prerequisites
Before starting with this tutorial we assume that you already have Kotlin installed (If you do not have Kotlin installed then install it before you get started) as well as a local programming environment set up on your computer.
Step 1:- Create a file called “helloworld.kt” using a text editor program of your choice. The .kt file extension is used to specify Kotlin language file.
Step 2:- Let’s open the “helloworld.kt” file that we created, and put the following line of code in it and save it.
1 2 3 |
fun main(args: Array<String>) { println("Hello, World!") } |
The println() is a function that tells Kotlin to display or output the content inside the parentheses.
Now, when we run this program it will print “Hello World!”.
Output:-
1 |
Hello World! |