BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Kotlin Hello World Program – First Kotlin Program

Last Updated: February 20, 2019 by Chaitanya Singh | Filed Under: Kotlin Tutorial

Lets write a simple Kotlin program to display “Hello World” message on the screen. With the help of this simple program we will try to understand the basics of Kotlin Programming.

You can run Kotlin program in Eclipse IDE or the popular IntelliJ IDEA IDE. You can refer the following tutorials to learn, how to create and run your first Kotlin programs in these IDEs.
1. Create and Run Kotlin Project in Eclipse IDE
2. Create and Run Kotlin Project in IntelliJ IDEA IDE

Hello World Program in Kotlin

// Display Hello World! on screen
fun main(args : Array<String>) {
    println("Hello World!")
}

Output:

Hello World!

Lets discuss Hello World Program in detail

1. The first line of the program is:

// Display Hello World! on screen

This is a comment. You can write anything here, the compiler ignore these comments while executing the program. Comments improve the code readability so when a programmer reads them, they can easily understand the purpose of code, by just reading the comment.

2. The second line of the program is:

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

This is the main function. Similar to java, the execution of the Kotlin program starts from this function. This function is the starting point of the Kotlin program. This is the mandatory function of the Kotlin program.

3. The third line of the program is:

println("Hello World!")

This is similar to the System.out.println(“Hello World!”) statement in java. The purpose of this statement to display the message inside double quotes on the screen.

❮ PreviousNext ❯

Top Related Articles:

  1. Kotlin – How to take Input from User
  2. Kotlin Tutorial for Beginners | Learn Kotlin
  3. Kotlin Keywords, Soft Keywords and Identifiers
  4. Kotlin Abstract Class with examples
  5. Kotlin break Statement with examples

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Kotlin Tutorial

  • Kotlin Tutorial
  • Kotlin in Eclipse IDE
  • Kotlin in IntelliJ
  • First Kotlin Program
  • Kotlin Keywords
  • Kotlin Variables
  • Kotlin Type Casting
  • Kotlin operators
  • Kotlin Input/Output
  • Kotlin Comments

Kotlin String

  • Kotlin String

Kotlin Array

  • Kotlin Array
  • Kotlin Range

Control Flow

  • Kotlin if expression
  • Kotlin when expression
  • Kotlin for loop
  • Kotlin while loop
  • Kotlin do-while loop
  • Kotlin continue
  • Kotlin break

Kotlin Function

  • Kotlin Function
  • Kotlin Recursion
  • Kotlin default and named arguments
  • Lambda functions
  • Higher Order Function

Exception Handling

  • Exception Handling
  • Kotlin try catch
  • Multiple catch blocks
  • Nested try catch
  • Throw keyword
  • Kotlin try expression

Kotlin OOP

  • Class and Objects
  • Kotlin Constructors
  • Kotlin Inheritance
  • Visibility Modifiers
  • Kotlin abstract class
  • Kotlin Interfaces
  • Nested and Inner Class
  • Kotlin Data Class
  • Kotlin Sealed Class

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap