Cover image of Kotlin + Android Studio Combo

Kotlin + Android Studio Combo

Photo by Louis Tsai on Unsplash

Kotlin + Android Studio, the combo I never expected to be this good.

At first, I highly doubt using Kotlin with Android Studio would be good idea. A friend of mine shows me snippet of his code, and I gotta say :

Kotlin surely is another unique language

Let's see some of the examples. For this purpose, I created Android project with Empty Activity with Java as well with Kotlin.

This first example is MainActivity.kt , the Main Activity of Android app but written in Kotlin:.

MainActivity in Kotlin

And here's the example of the same file, MainActivity but in Java:

MainActivity in Java

Right away, we saw two different style.

  • Kotlin use "fun" as the way to declare a function (and probably kind of sick joke from the developer). As for Java, we don't use this.
  • Extending class is rather simplified by using colon ( : ). This might throw off fellow Android developer who previously working with Java (I was that person, too)