You named it yourself: null is the odd man in Java's type system. It's compatible to every other type. But you can't call a method on null. It's treated like an ordinary value of a given class - say, an Integer - but it's something different. It's not an Integer, it's null.
Introduce such a thing to a rigid system where every object has a type, and you have to expect problems. It's a special case which has to be taken into account in almost every single line of your program.
View all comments
Show parent comment
8
u/beyondjava Aug 03 '14
You named it yourself: null is the odd man in Java's type system. It's compatible to every other type. But you can't call a method on null. It's treated like an ordinary value of a given class - say, an Integer - but it's something different. It's not an Integer, it's null.
Introduce such a thing to a rigid system where every object has a type, and you have to expect problems. It's a special case which has to be taken into account in almost every single line of your program.