kotlin
  1. kotlin-first-program-concept

Kotlin First Program Concept

Syntax

The syntax for writing the first program in Kotlin is as follows:

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

Example

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

Output

The output of the above program will be:

Hello, World!

Explanation

In the above program, we have defined a function named main which takes an array of strings as a parameter. Inside this function, we are using the println function to output the string "Hello, World!"

Use

The first program in Kotlin is used to get familiarized with the language and to understand the basic structure of a Kotlin program.

Important Points

  • The fun keyword is used to define a function in Kotlin.
  • The main function is the entry point of a Kotlin program.
  • The println function is used to output text to the console.

Summary

In this tutorial, we learned how to write the first program in Kotlin using the println function to output text to the console. The main function serves as the entry point of a Kotlin program and the fun keyword is used to define functions in Kotlin.

Published on: