Null Safety
Understand Kotlin's null safety system: nullable types, the safe call operator, the Elvis operator, and how to eliminate NullPointerExceptions.
The Billion-Dollar Mistake
In Java, any variable can be null, causing a NullPointerException (NPE) at runtime — one of the most common crashes in Android apps.
Tony Hoare, who invented null, called it his billion-dollar mistake.
Kotlin eliminates NPEs at compile time with its null safety system.
Nullable vs Non-Nullable
In Kotlin, types are non-nullable by default. To allow null, add ? to the type:
String— never null, guaranteedString?— can be null
The compiler enforces this — it won't let you assign null to a non-nullable type.