kotlin
  1. kotlin-hello-world-program

Kotlin Hello World Program

Syntax

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

Example

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

Output

Hello, World!

Explanation

The above Kotlin program is a simple example of a "Hello World" program.

  • The fun keyword in front of main signifies that it is a function.
  • main is the entry point of any Kotlin program.
  • (args: Array<String>) is the parameter list. Here, args represents the command-line arguments passed to the program and Array<String> specifies that the parameter is an array of strings.
  • The println() function is used to print out the string "Hello, World!" to the console.

Use

The "Hello World" program is a simple program that is used to demonstrate the basic syntax of a programming language. It is usually the first program written by beginners in any programming language.

Important Points

  • main() function is the entry point of the Kotlin program.
  • args represents the command-line arguments passed to the program.
  • println() function is used to print out the string to the console.

Summary

In this tutorial, we learned how to write a "Hello World" program in Kotlin. We covered the basic syntax, example, output, explanation, use, important points, and summary of the program. The "Hello World" program is a simple program used to demonstrate the basics of a programming language.

Published on: