title: Java operator precedence guidelines
body: <p>Misunderstanding <strong>Java operator precedence</strong> is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the <a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15" rel="nofollow noreferrer"><em>Java Language Specification</em></a> says, &quot;It is recommended that code not rely crucially on this specification.&quot; <a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.7" rel="nofollow noreferrer">JLS §15.7</a> Preferring <em>clear</em> to <em>clever</em>, are there any useful guidelines in this area?</p>
  <p>As noted <a href="https://stackoverflow.com/a/13353263/230513">here</a>, this problem should be studied in the context of <a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.7" rel="nofollow noreferrer"><em>Evaluation Order</em></a>, detailed <a href="https://stackoverflow.com/q/6800590/230513">here</a>. Here are a number of resources on the topic:</p>
  <ul>
  <li><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.12" rel="nofollow noreferrer">JLS Operators</a></li>
  <li><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.7" rel="nofollow noreferrer">JLS Precedence</a></li>
  <li><a href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.7" rel="nofollow noreferrer">JLS Evaluation Order</a></li>
  <li><a href="https://stackoverflow.com/q/6800590/230513">What are the rules for evaluation order in Java?</a></li>
  <li><a href="http://mindprod.com/jgloss/precedence.html" rel="nofollow noreferrer">Java Glossary</a></li>
  <li><a href="http://www.cs.princeton.edu/introcs/11precedence/" rel="nofollow noreferrer">Princeton</a></li>
  <li><a href="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html" rel="nofollow noreferrer">Oracle Tutorial</a></li>
  <li><a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html" rel="nofollow noreferrer">Conversions and Promotions</a></li>
  <li><a href="http://groups.google.com/group/comp.lang.java.programmer/browse_frm/thread/53e1b79100e7dd01" rel="nofollow noreferrer">Usenet discussion</a></li>
  </ul>
  <p>Additions or corrections welcome.</p>