Monday, 2 September 2013

Java: How does Java read this statement?

Java: How does Java read this statement?

I have this expression in the if else statement
if (row % 2 == 0 && col % 2 == 0 || row % 2 == 1 && col % 2 == 1) {
return 0;
}
else {
return 1;
}
which behaves as intended, returning 0 when the row and column are either
both even or both odd. What perplexes me is how Java didn't read it as
(row % 2 == 0 && (col % 2 == 0 || row % 2 == 1 && col % 2 == 1))
How exactly does Java read a statement without parens?

No comments:

Post a Comment