2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

what is the basic difference between null == object and object == null

what is the basic difference between  null == object and object == null

basically, sometimes people prefer to go for null == object and some times object == null

what is the right way to do so.

userimage

object.getItems() == null and null == object.getItems() are equivalent.

Perhaps you're mixing it up with the fact that

nonNullObj.equals(obj)

and

obj.equals(nonNullObj)

can make a difference (since the second alternative could result in a NPE in case the callee is null).

Answer is