Kotlin course

Kotlin It's a kind of in Java A statically typed programming language running on a virtual machine , It is called Android The of the world Swift, from JetBrains Design, develop and open source .

Kotlin Can be compiled into Java Bytecode , It can also be compiled into JavaScript, Convenient without JVM Run on your device .

stay Google I/O 2017 in ,Google announce Kotlin become Android Official development language .


My first Kotlin Program

Kotlin The program file is written in .kt ending , as :hello.kt 、app.kt.

Minimalist version

package hello // Optional Baotou fun main ( args : Array < String > ) { // Package level visible functions , Accept an array of strings as arguments println ( " Hello World! " ) // Semicolons can be omitted }

Run instance »

object-oriented

class Greeter ( val name : String ) { fun greet ( ) { println ( " Hello, $name " ) } } fun main ( args : Array < String > ) { Greeter ( " World! " ) . greet ( ) // Create an object without new keyword }

Run instance »

Why choose Kotlin?

  • concise : Greatly reduce the number of boilerplate code .
  • Safe : Avoid null pointer exceptions and other errors of the whole class .
  • Interoperability : make the best of JVM、Android And the browser's existing library .
  • Tool friendly : You can use any Java IDE Or use the command line to build .

Reference link