androidkotlindisambiguation

How to tell the difference between Java and Kotlin code?


As a beginner to Android app development, I am finding code examples that do not identify whether they are written in Java or Kotlin. Even StackOverflow questions frequently omit the language tag.

Is there an easy "tell" in the code where you can immediately see which language is used? For example, I can distinguish C and C++ very quickly from certain elements of the syntax, header use, and library functions.

Are there any quick and "obvious" ways to distinguish Java from Kotlin? I want to be exploring Kotlin and not adding to my (immense) confusion by studying irrelevant code.


Solution

  • some obvious traits for kotlin:


    personally for me the biggest indicator:

    fun :) function declaration :

    fun foo(): String