# Advantages of Using Nullable Instead of lateinit

The importance of catching errors at compile time.

- **Source:** [ProAndroidDev - Medium](https://brifing.si/source/d9553fa9-7b72-4b9b-bc73-c6bf9a40dd5f)
- **Published:** 2026-07-11
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://proandroiddev.com/stop-using-lateinit-make-it-nullable-instead-b6bc67db1f58?source=rss----c72404660798---4>
- **On Brifing:** https://brifing.si/s/8ab56def-e6ad-4704-bffb-45ff1f09fdbb

## Comparison of lateinit and Nullable

In Kotlin, lateinit and nullable variables exhibit different behaviors during variable initialization and access. While lateinit allows delaying initialization, nullable variables explicitly indicate null values. These approaches yield different results in preventing application errors.

## What is Null Pointer Exception?

Null pointer exception occurs when a variable or property is accessed while holding a null value. This is a common error in languages like Java and Kotlin and can cause the application to crash. Kotlin's null safety feature helps prevent such errors.

## Uninitialized Property Access Exception

This Kotlin-specific exception occurs when a lateinit variable is accessed without being initialized. This situation is frequently seen in Android applications, especially when variable initialization is forgotten in methods like onCreate().

## Null Safety in Kotlin

Kotlin prevents null values from being assigned to variables through its null safety feature. This ensures errors are caught at compile time. Nullable variables can be safely accessed using the safe call operator (?.), preventing application crashes.

## Risks of Using lateinit

Using lateinit can lead to serious errors if variable initialization is forgotten. New developers might forget to add the isInitialized check, causing the application to crash. These risks can be mitigated by using nullable variables.

## Advantages of Using Nullable

Nullable variables ensure errors are caught at compile time and prevent application crashes. Null values can be safely handled using the safe call operator (?.). This approach offers a safer and more error-resistant code structure compared to lateinit.

## Sources covering this story

- https://proandroiddev.com/stop-using-lateinit-make-it-nullable-instead-b6bc67db1f58?source=rss----c72404660798---4 — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
