Sometimes, I see this:
if (a.equals(b)) do(something);
However, if a is null, a NullPointerException is thrown. Assuming when a==null and b==null or if just a==b that I would want to do(something). What's the simplest way to do this check without getting an exception?
Another way of writing it.
if (a == null ? b == null : a.equals(b))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With