NullPointerException
The unchecked exception thrown when code uses a null reference as if it pointed to an object.
In more detail
NPE is the common abbreviation. It happens when calling a method on null, reading a field of null, or unboxing a null wrapper. Modern JVMs print a helpful message naming exactly which expression was null.
Related terms
- null — A special value meaning no value or no object, set on purpose to show that something is empty or absent.
- unchecked exception — An exception type, extending RuntimeException, that the compiler does not force callers to catch or declare.
- boxing — The automatic conversion between a primitive, such as int, and its wrapper object, such as Integer, which the compiler inserts for you.
- Optional — A container that holds either one value or nothing, used as a return type to make "no result" visible to the caller.
Taught in
- Primitive And Reference Types — Modern Java: Virtual Threads & High-Throughput Services
- Handling Nulls With Optional — Modern Java: Virtual Threads & High-Throughput Services
- Promotion, Wrappers And The Math API — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Overloading And Varargs — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Scope, var And Immutable Objects — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sealed Types, Casts And Pattern Matching — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Object-Oriented Java — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Lists, Sets, Maps, Deques And Sequenced Collections — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Lambdas, Functional Interfaces And Method References — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Stream Pipelines, Primitive Streams And Optional — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Concurrent Collections And Parallel Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Console And File I/O With Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: I/O And Localization — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep