On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers. Since the release of Android Studio 3.0 in October 2017, Kotlin has been included as an alternative to the standard Java compiler. The Android Kotlin compiler targets Java 6 by default, but lets the programmer choose between Java 8 to 13, for optimization.
Kotlin relaxes Java’s restriction of allowing static methods and variables to exist only within a class body. Static objects and functions can be defined at the top level of the package without needing a redundant class level. For compatibility with Java, Kotlin provides a
JvmName annotation which specifies a class name used when the package is viewed from a Java project. For example,
Semicolons are optional as a statementterminator; in most cases a newline is sufficient for the compiler to deduce that the statement has ended.
Kotlin variable declarations and parameter lists have the data type come after the variable name (and with a colon separator), similar to Pascal and TypeScript.
Variables in Kotlin can be read-only, declared with the val keyword, or mutable, declared with the var keyword.
Class members are public by default, and classes themselves are final by default, meaning that creating a derived class is disabled unless the base class is declared with the open keyword.
In addition to the classes and methods (called member functions in Kotlin) of object-oriented programming, Kotlin also supports procedural programming with the use of functions.Kotlin functions (and constructors) support default arguments, variable-length argumentlists, named arguments and overloading by unique signature. Class member functions are virtual, i.e. dispatched based on the runtime type of the object they are called on.