Was `if (x = 0)` ever compiled Java

I was intrigued by what Scott Ambler says in his Java Coding Standards book , and I quote:

2.5.2 Place the constants on the left side of the comparisons

Therefore, he recommends using

if ( 1 == something ) {…}    
if ( 0 = x ) { …}

instead

if ( something == 1 ) {…}    
if ( x = 0 ) { …}  

OMG !!!

And he motivates this by saying that:

"Although they are both equivalent, at least at the first inspection, the code on the left compiles , and the code on the right does not."

As I know (when I started programming Java, Java 14. was already used), both conditions will throw a compiler error.

Starting with the Ambler instruction, I tried to search when the Java syntax if ( x = 0 );was ever compiled.

? JSR, , , Java.

Jre7 target source 1.2 . , Java 1.1: 9

:

if(x = 0); Java?

+4
2

if ( x = 0 ) { …} if ( 0 = x ) { …} . , if boolean, x=0 -

secondly 0=x .0 = x , x 0, .

if ( something == 1 ) {…} instead of if ( 1 == something ) {…} , == .equals() , , == .eqauls() link1 link2

+5

. if (x=true) , x .

+4

All Articles