mercredi 21 octobre 2015

Java - Having AND and OR in the same condition, without parentheses [duplicate]

This question already has an answer here:

I know that using And (&&) and OR (||) in a condition statement shouldn't be used without parentheses.

So if you should use both conditions you should do (A && !B) || (C && D)

However, in some code I saw that they are not using Parentheses? What would happen then? I thought that didn't compile:

A && !B || C && D

I guess that it would resolve as with SUMS or MULTIPLICATIONS, I mean, resolve them as they are read:

(((A && !B) || C) && D)

Aucun commentaire:

Enregistrer un commentaire