I would be grateful if someone could please explain why the following is occuring. Thanks a lot.
boolean b = true; // Compiles OK. // The LHS "assignment operand" requires no ()parentheses. if (b=true || b==true); // Reverse the ||'s operands, and now the code doesn't compile. if (b==true || b=true); // Add () around the RHS "assignment operand", and the code now compiles OK. if (b==true || (b=true)); Edit -
BTW, the compilation error for code line #2 is: "unexpected type", and occurs where the short-circuit OR operator is located:
if (b==true || b=true); // ^ "unexpected type" compilation error occurs here. Edit 2 -
Please note that the code fragments found in this question are examples of "highly artificial Java coding", and consequently would not be seen in professionally written code.
Edit 3 -
I'm new to this incredibly useful website, and I've just learnt how to make and upload screenshots of Java's compilation messages. The following image replicates the information that I provided in my first "Edit" above. It shows the compilation error for example code line #2.

if (b==true || b=true); required: variable, found: value