object==null or null==object?

This is probably a habit learned from C, to avoid this sort of typo (single = instead of a double ==):

if (object = null) {

The convention of putting the constant on the left side of == isn’t really useful in Java since Java requires that the expression in an if evaluate to a boolean value, so unless the constant is a boolean, you’d get a compilation error either way you put the arguments. (and if it is a boolean, you shouldn’t be using == anyway…)

Leave a Comment