(obj == null) vs (null == obj)?

Viewed 24107

My boss said I should use null == obj, because it's better than obj == null, but he didn't remember why to do this. Is there any reason for using null == obj?
I feel it somehow... opposite!

After some search on Google, the only thing I found is:

in C, it prevents you accidentally from typing (obj = null) in a conditional structure.

6 Answers

:)

One thing I've found useful about this is that the below syntax (absolutely valid from my POV) is not causing spotbugs' DC-DOUBLECHECK warning, allowing to raise spotbugs threshold without any special exclusion etc:

if (defaultClient == null) {
    synchronized (DEFAULT_CLIENT_INIT_LOCK) {
        if (null == defaultClient) {
            ...
        }
    }
}
Related