I was watching a java programming video tutorial, and it was mentioning that:
if(null != x){
}
is it a good practice to use it like above ?
Does it differ from :
if(x != null){
}
You're going to want to use the second one.
Both do the same exact thing...compare A to B, or compare B to A - both mean the same thing.
It just makes more sense to use x != null
because that is more like how we would say this.
You could ask me "Is x not null?" That seems more natural than "Is null not x?" It makes more sense to us.
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