Kotlin is the language Google recommends for Android. It interoperates with Java on the JVM: you can call Java APIs and migrate file by file. Kotlin adds null safety, data classes, default arguments, and coroutines. Java remains in older modules and some backend stacks — you will read both.
This Kotlin cheat sheet is written for people searching for a fast, accurate reference: students, junior developers, and teams shipping production software. Pin it, copy the snippets, and come back when syntax slips.
Quick reference
- Null: Kotlin
StringvsString?. Java@Nullablemaps to platform types you should wrap. - val/var: Replace Java
finalfields and getters with properties. - Data class: Replaces Java record-like POJOs with
equals/copywithout boilerplate. - Default args: Cuts Java builder noise for optional parameters.
- SAM: Kotlin lambdas implement Java single-method interfaces.
- Checked exceptions: Kotlin does not require
throws. You still handle IOException at boundaries. - Coroutines: Replace many Java callback/thread patterns on Android.
- Interop:
@JvmStatic,@JvmOverloads,@JvmFieldwhen Java callers need nicer signatures.
Copy-paste examples
Same model in Kotlin
The Java version would be a class with getters, equals, hashCode, and a constructor. Kotlin’s data class is the usual replacement.
data class User(val id: Int, val email: String, val name: String? = null)
fun displayName(user: User): String =
user.name?.ifBlank { null } ?: user.email.substringBefore('@')Common mistakes
- Calling Java that returns null into a non-null Kotlin type and crashing at the boundary.
- Writing Java-style getters (
getTitle()) instead ofval titlein new Kotlin. - Assuming Kotlin is “just Java syntax” and ignoring null safety in reviews.
- Mixing
!!to silence the compiler while keeping Java-nullable APIs unwrapped.
FAQ
- Can Kotlin call Java libraries? Yes. The Android SDK and most Maven libraries are Java. You write Kotlin against them daily.
- Can Java call Kotlin? Yes. Default parameters need
@JvmOverloadsif Java should see overloads. File-level functions becomeXxxKtclasses.
- Should I convert a whole Java app at once? No. Convert on touch. New features in Kotlin. Tests help when you change nullability.
Related Kotlin cheat sheets
Build with this stack
When a cheat sheet is not enough — you need a production app, a student FYP, or a custom dashboard — ArpaNeuro builds mobile app development and also sells ready-made source code. Request a quote and tell us the stack.
Browse software development services or the source code marketplace if you want a working codebase instead of starting from a blank file.