Bitwise AND (&) expression in Java
I am debugging code that has in it expr1 & expr2 where expr1 has a side effect that affects expr2 evaluation result. I suspect that expr2 gets evaluated before expr1 , since JLS guarantees left-to-right evaluation for && , but not necessarily for & . I also suspect that change of evaluation order may be a result of optimization performed by HotSpot (we're running Java 6u20). Do you know if HotSpot can make such an optimization? Better yet, provide any pointers to documentation that either support or eliminate the suspicion. Thanks in advance. EDIT: Thanks for those suggesting to rewrite the