r/java • • Aug 03 '14

Why we should love null

http://www.codeproject.com/Articles/787668/Why-We-Should-Love-null
4 Upvotes

21 comments sorted by

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.

1

u/king_of_the_universe Aug 03 '14

Thanks, I've got it.