Is there a difference between (null! = X) and (x! = Null)

I watched a video tutorial on java programming and he mentioned that:

if(null != x){ } 

Is it good to use it as stated above?

Does it differ from:

 if(x != null){ } 
+5
source share
2 answers

You will want to use the second.

Both do the same ... compare A with B or compare B with A - both mean the same thing.

It just makes sense to use x != null , because it is more like the way we say it.

You can ask me: "Is x not null?" This seems more natural than "Is null not x?" It makes more sense to us.

+5
source

I think the most common method is the latter, but both achieve the same.

+2
source

Source: https://habr.com/ru/post/1206372/


All Articles