10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

EXPRESSIONS Evaluation Order for Other Expressions 15.7.5<br />

If evaluation of an argument expression completes abruptly, no part of any<br />

argument expression to its right appears to have been evaluated.<br />

Thus, the example:<br />

class Test {<br />

static int id;<br />

public static void main(String[] args) {<br />

try {<br />

test(id = 1, oops(), id = 3);<br />

} catch (Exception e) {<br />

System.out.println(e + ", id=" + id);<br />

}<br />

}<br />

static int oops() throws Exception {<br />

throw new Exception("oops");<br />

}<br />

static int test(int a, int b, int c) {<br />

return a + b + c;<br />

}<br />

}<br />

prints:<br />

java.lang.Exception: oops, id=1<br />

because the assignment of 3 to id is not executed.<br />

15.7.5 Evaluation Order for Other Expressions<br />

<strong>The</strong> order of evaluation for some expressions is not completely covered by these<br />

general rules, because these expressions may raise exceptional conditions at times<br />

that must be specified. See, specifically, the detailed explanations of evaluation<br />

order for the following kinds of expressions:<br />

• class instance creation expressions (§15.9.4)<br />

• array creation expressions (§15.10.1)<br />

• method invocation expressions (§15.12.4)<br />

• array access expressions (§15.13.1)<br />

• assignments involving array components (§15.26)<br />

DRAFT<br />

419

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!