Kotlin Hello World

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

Explanation:
 * fun main(args: Array<String>):
   * This line defines the main function, which is the entry point of the Kotlin program.
   * fun is the keyword for declaring a function.
   * main is the name of the function.
   * args: Array<String> is the parameter of the main function, which represents an array of command-line arguments passed to the program.
 * println("Hello, World!"):
   * This line prints the text "Hello, World!" to the console.
   * println() is a built-in function in Kotlin that prints the given string to the console and adds a newline character at the end.
To run this code:
 * Save the code: Save the code in a file named HelloWorld.kt.
 * Compile the code: Use the Kotlin compiler (kotlinc) to compile the code:
   kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar

 * Run the compiled code:
   java -jar HelloWorld.jar

This will output:
Hello, World!

This is the most basic example of a Kotlin program, demonstrating the fundamental syntax and how to print output to the console.

Comments

Popular posts from this blog

Kotlin Math Operations and Functions Overview

Kotlin Strings: Features and Operations Guide

Kotlin Android Program (QCR) Application Codes That Read Text in Photos