Kotlin Tutorial
# Kotlin Tutorial
!(#)
Kotlin is a statically typed programming language that runs on the Java Virtual Machine, also known as the Swift of the Android world, designed and developed by JetBrains and open-sourced.
Kotlin can be compiled to Java bytecode or to JavaScript, making it convenient to run on devices without a JVM.
At Google I/O 2017, Google announced Kotlin as an official development language for Android.
* * *
## My First Kotlin Program
Kotlin program files end with .kt, for example: hello.kt, app.kt.
## Minimal Version
package hello// Optional package header fun main(args: Array){// Package-level function that accepts an array of strings as a parameter println("Hello World!")// Semicolons can be omitted}
[Run Example Β»](#)
## Object-Oriented
class Greeter(val name: String){fun greet(){println("Hello, $name")}}fun main(args: Array){Greeter("World!").greet()// No need for the 'new' keyword to create an object}
[Run Example Β»](#)
* * *
## Why Choose Kotlin?
* Concise: Drastically reduces the amount of boilerplate code.
* Safe: Avoids entire classes of errors such as null pointer exceptions.
* Interoperable: Leverages existing libraries for JVM, Android, and the browser.
* Tool-friendly: Can be used with any Java IDE or built from the command line.
* * *
## Reference Links
* (http://www.kotlinlang.org/)
* (http://try.kotlinlang.org/)
* (https://www.kotlincn.net/)
* (https://play.kotlinlang.org/)
* (
YouTip