One disadvantage of using operators is that the parentheses are often easily mistaken. It is easy to confuse the use of parentheses even if there is a slightest uncertainty about how an expression is evaluated. This problem still exists in Java.
In C and C + +, a particularly common error is as follows:
while (x = y) {
//...
}
The intention of the program is to test for "equal" (= =), rather than for assignment operations. In C and C + +, if Y is a non 0 value, then the result of this assignment is definitely true. This makes it possible to get an infinite loop. In Java, the result of this expression is not a Boolean value, and the compiler expects a Boolean value that is not converted from an int value. So when compiling, the system prompts for an error that effectively prevents us from running the program further. So this shortcoming in Java will never cause more serious consequences. The only thing that does not get compilation errors is that both X and Y are Boolean values. In this case, x = y is a valid expression. In this case, it could be an error.
In C and C + +, a similar problem is to use bitwise AND and OR, rather than logical and and OR. Use one of two characters (& or |) by bitwise AND And OR, while logical and and or using two identical characters (&& or | | )。 Just like "=" and "=", typing a character is certainly easier than typing two. In Java, the compiler can also prevent this, because it does not allow us to force a type that does not belong.