Java Pitfalls - Nulls and NullPointerException

suggest change

Remarks

The value null is the default value for an uninitialized value of a field whose type is a reference type.

NullPointerException (or NPE) is the exception that is thrown when you attempt to perform an inappropriate operation on the null object reference. Such operations include:

The most common root causes for NPEs:

Examples of commonly used methods that return null include:

There are strategies for avoiding unwanted NPEs, such as explicitly testing for null or using “Yoda Notation”, but these strategies often have the undesirable result of hiding problems in your code that really ought to be fixed.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Pitfalls - nulls and NullPointerException:
* Java Pitfalls - Nulls and NullPointerException

Table Of Contents
8 Arrays
10 Maps
11 Strings
25 JAXB
29 Enums
32 Audio
41 Scanner
63 Logging
75 Lists
78 Sets
89 JAX-WS
96 XJC
98 Process
106 Modules
114 Applets
120 Pitfalls - nulls and NullPointerException
122 JNDI
139 JavaBean
141 Literals
144 Packages
150 JMX
153 JShell
159 Sockets
167 Enum Map
175 Hashtable
177 SortedMap