Saturday, October 26, 2019

Kotlin Android tutorial

Kotlin tutorial is a statically typed programming language that runs on the Java virtual machine and is called Swift in the Android world. It is designed and developed by JetBrains and is open source.
Kotlin can be compiled into Java bytecode or compiled into JavaScript for easy operation on devices without a JVM.
Kotlin Android tutorial

In Google I/O 2017, Google announced that Kotlin is the official Android development language.

My first Kotlin program

Kotlin program files end with .kt, such as hello.kt, 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: Significantly reduce the number of boilerplate code.
Security: Avoid errors such as null pointer exceptions for the entire class.
Interoperability: Take advantage of existing libraries for JVM, Android, and browsers.
Tool friendly: Works with any Java IDE or with the command line.

No comments:

Post a Comment