Agree, this is a wrongheaded article. Personally I'm becoming increasingly enamored of Google Guava's immutable datatypes and functional-style programming to deal with this class of problems. Nulls suck, but I think they are mostly an artifact of having mutable data structures.
Articles like this is where bad Java style comes from.
In real life you:
use commons APIs to check for empty objects, collections, etc;
treat exceptions like they are, well, exceptional and not like they are form of "if" statement;
never test Enumeration values for equality using object.equals();
dont use assert class like shown. You just add more complexity and gain nothing but exchange NPE for IAE.
and so on and so on.
Null Pointer Exception is the most common and most annoying exception in Java. In this post I want to avoid this undesired exception. First let's create example that raise Null Pointer Exception p...
Add a comment...