Sunday, April 12, 2020

Kotlin tutorial

Kotlin is a statically typed programming language that runs on a Java virtual machine. It is called Swift in the Android world, designed and developed by JetBrains and open source.
Kotlin can be compiled into Java bytecode or JavaScript, making it easy to run on devices without a JVM.
In Google I / O 2017, Google announced that Kotlin has become the official development language of Android.
Kotlin tutorial

My first Kotlin program
Kotlin program files end with .kt , such as hello.kt and app.kt
package hello
fun main(args: Array<String>) {
   println("Hello World!")
}
Object-oriented
class Greeter(val name: String) {
   fun greet() {
      println("Hello, $name")
   }
}

fun main(args: Array<String>) {
   Greeter("World!").greet()
}
Why choose Kotlin?

  • Concise: greatly reduce the amount of boilerplate code.
  • Security: Avoid the entire class of errors such as null pointer exceptions.
  • Interoperability: Make full use of existing libraries of JVM, Android and browser.
  • Tool-friendly: Can be built with any Java IDE or using the command line.

No comments:

Post a Comment