In some languages you can use this shorthand. For example, in Python, a == b == c roughly equivalent to the expression a == b and b == c , except that b is evaluated only once.
However, in Java and Javascript you cannot use the short version - you must write it, as in the second example. The first example will be approximately equivalent to the following:
boolean temp = (a == b); if (temp == c) {
This is not what you want. In Java, a == b == c does not even compile if c not logical.
source share