Easy Tutorial
❮ Kotlin Object Declarations Kotlin Class Object ❯

Kotlin Tutorial

Kotlin is a statically typed programming language that runs on the Java Virtual Machine, known as the Swift of the Android world, designed and developed by JetBrains and open-sourced.

Kotlin can be compiled into Java bytecode, and it can also be compiled into JavaScript, facilitating operation on devices without a JVM.

At Google I/O 2017, Google announced Kotlin as the official Android development language.


My First Kotlin Program

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

Minimalist Version

package hello                      // Optional package header

fun main(args: Array<String>) {    // Package-visible function, accepts an array of strings as an argument
   println("Hello World!")         // Semicolons can be omitted
}

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
}

Why Choose Kotlin?


Reference Links

❮ Kotlin Object Declarations Kotlin Class Object ❯