Kotlin tutorial


Release date:2023-09-20 Update date:2023-10-13 Editor:admin View counts:335

Label:

Kotlin tutorial

Image0

Kotlin is a statically typed programming language that runs on the Java virtual machine, known as the Android world Swift designed, developed and open source by JetBrains .

Kotlin can be compiled into Java bytecode or into JavaScript, making it easyto run on devices without JVM.

In Google I Dot O 2017, Google announced Kotlin become the official development language of Android.

My first Kotlin program

Kotlin program files to .kt the end, such as: hello.ktapp.kt .

Simplest version

package hello                      //  Optional Baotou

fun main(args: Array<String>) {    // A package level visible
function that accepts an array of strings as parameters
   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 without the new keyword
}

Why choose Kotlin?

  • Simplicity: greatly reduces the amount of boilerplate code.

  • Security: avoid errors of the entire class, such as null pointer exceptions.

  • Interoperability: take full advantage of existing libraries of JVM, Android,and browsers.

  • Tool-friendly: can be built with any Java IDE or using the command line.

Reference link

Official website

Official website

Official website - Chinese translation

Kotlin Official Online Tool

Powered by TorCMS (https://github.com/bukun/TorCMS).