DELAPARRA
Index
Color
NL
Category: Error types

NullPointerException

Explained by Updated

What is NullPointerException?

NullPointerException: The code tries to use an object reference that points to nothing (null). Mostly a Java / Kotlin / C# concept. A NullPointerException in Java, Kotlin or C# happens when code tries to use an object reference that points to nothing. Calling user.getName() when user is null is the classic example. PHP's equivalent is "Call to a member function on null".

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about NullPointerException

How is NullPointerException used in practice?

The stack trace shows where it crashed, but the real bug is usually earlier, where the null value came from. A lookup that found nothing, an optional field left empty, or a value never initialised.

What should you keep in mind with NullPointerException?

Fix the source rather than adding null checks everywhere. Make it explicit which values may be null, handle the empty case where data enters the system, and use language features that help. Kotlin's type system separates nullable and non-null types, Java has Optional, and in PHP, nullable types plus static analysis catch most cases before they reach production.

At a glance

CategoryError types
Explained by
Updated

More Error types terms

All terms starting with N

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.