Is there a difference between (null == var) and (var == null)

I want to know the differences between the two conditional expressions null == varand the var == nullif statement in Java.

-2
source share
4 answers

There is no difference. Just a matter of style.

And the first, named yoda style

In jargon programming, Yoda conditions (also called Yoda notation) are a programming style in which two parts of an expression are referenced in a conditional expression.


null == var var == null . , misspell == ( ) = (), var = null . , null == var misspells null = var, . , . .

Criticism :

, , . ( , , ). " ". .

+8

. ,

String x = null;
if(x==null)
{
    System.out.println("null");
}
if(null==x)
{
    System.out.println("no diff");
}

null
no diff

,

+1

, . , var - null.

0

All Articles