Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Kotlin Tutorial

Kotlin Tutorial

Kotlin is a statically typed programming language that runs on the Java Virtual Machine, developed by JetBrains.

Kotlin has concise syntax, built-in null safety, and interoperates with Java code, making it the official preferred language for Android development.

Kotlin can be compiled to Java bytecode or to JavaScript, making it easy to run on devices without a JVM.

This tutorial is based on Kotlin 2.2 and takes you from zero to mastering Kotlin's syntax, object-oriented programming, collections, coroutines, and engineering practices.


My First Kotlin Program

Kotlin program files end with .kt, such as hello.kt and app.kt.

Minimal version

package

hello

//

Optional package header

fun

main

(

args

:

Array

<

String

)

{

//

A package-level visible function that takes an array of strings as a parameter

println

(

"

Hello World!

"

)

//

Semicolons can be omitted

}

Run Example »

Object-oriented

class

Greeter

(

val

name

:

String

)

{

fun

greet

(

)

{

println

(

"

Hello, $name

"

)

}

}

fun

main

(

args

:

Array

<

String

)

{

Greeter

(

"

World!

"

)

.

greet

(

)

//

Creating an object does not require the new keyword

}

Run Example »


Why choose Kotlin?


Reference Links