NullPointerException
NullPointerException is a Java runtime exception raised when code improperly dereferences or otherwise uses a null reference where an object is required.
100 Java Mistakes and How to Avoid Them
NullPointerException is the Java runtime exception raised when an operation dereferences or otherwise improperly uses a null reference.
- How it is used
- Frames null-related Java failures and prevention across APIs, varargs, initialization, and collections.
- How deep it goes
- Defines nullability concerns and develops focused failure mechanisms, stopping at prevention rules and tool guidance.
- Examples
- Uses null varargs casts, static field ordering, logger initialization, and Set.of contains(null) migration cases.
- What you can do after
- Diagnose/debug with it by tracing nullable flows, initialization order, varargs binding, and collection null policies.
Read how 100 Java Mistakes and How to Avoid Them explains NullPointerException →
Kotlin in Action, 2E
NullPointerException is a runtime exception raised when code dereferences a null reference where a non-null object is required.
- How it is used
- Uses nullability checks to prevent runtime dereference failures in JVM backends and Android applications.
- How deep it goes
- Explains nullable types and operators with a compact example, but defers deeper runtime and interoperability edge cases.
- Examples
- Demonstrates nullable and non-nullable String access and cites reduced Google Home crashes after Kotlin adoption.
- What you can do after
- Apply nullable types and Kotlin operators to prevent or explicitly handle possible null dereferences.
Read how Kotlin in Action, 2E explains NullPointerException →
Related concepts
- !! operatorproduced by · The !! operator is Kotlin's non-null assertion operator, which treats a nullable expression as non-null and throws an exception if it is null.
- Objects.requireNonNullproduced by · Objects.requireNonNull is a Java utility method that returns a non-null reference or throws NullPointerException when its argument is null.
- nullable typeaddressed by · A nullable type is a type whose values may be either a value of the underlying type or an explicit representation of absence, such as null.
- exceptionkind of · An exception is a runtime signal or object representing an abnormal condition that interrupts ordinary program flow and may be handled or propagated.
- defensive programmingaddressed by · Defensive programming is a technique that anticipates invalid inputs, failures, misuse, and unsafe states and explicitly guards against their harmful effects.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

