Simple Hello World program in kotlin
Author:
Views:
Category:
Basic start in kotlin
Simple start of Kotlin Programing

In this section we simply implement a hello world program, so that you can understand the basic of kolin. You can use Intellij or android studio IDE to practice kotlin language.

Hello World

An entry point to a Kotlin application is the main function. In Kotlin 1.3, you can declare main without any parameters. The return type is not specified, which means that the function returns nothing.

package org.prointellects.hello_world         

fun main() {                        			// 1
    println("Hello, World!")        			// 2
}

Kotlin code is usually defined in packages. Package specification is optional: If you don't specify a package in a source file, its content goes to the default package.

println writes a line to the standard output. It is imported implicitly. Also note that semicolons are optional

Output of above program will be Hello, World! in console window.

In Kotlin versions earlier than 1.3, the main function must have a parameter of type Array<String>.

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