Don't use obj != null - this approach might yield unexpected results when obj is an instance of a class that overloaded the == and != operator. Check out my post here on how to properly test for null / not null:
obj != null
==
!=
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Don't use
obj != null
- this approach might yield unexpected results when obj is an instance of a class that overloaded the==
and!=
operator.Check out my post here on how to properly test for null / not null:
The perfect non-null test
Zohar Peled ・ Nov 13 ・ 2 min read