Cheat Sheets

Kotlin vs Java Cheat Sheet: Null Safety, Data Classes & Interop

By ArpaNeuro Team September 18, 2026
Kotlin Java cheat sheet

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 String vs String?. Java @Nullable maps to platform types you should wrap.
  • val/var: Replace Java final fields and getters with properties.
  • Data class: Replaces Java record-like POJOs with equals/copy without 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, @JvmField when 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 of val title in 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

  1. Can Kotlin call Java libraries? Yes. The Android SDK and most Maven libraries are Java. You write Kotlin against them daily.
  1. Can Java call Kotlin? Yes. Default parameters need @JvmOverloads if Java should see overloads. File-level functions become XxxKt classes.
  1. 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.

← All Articles Get a Quote →