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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

EXPRESSIONS Class Instance Creation Expressions 15.9<br />

DISCUSSION<br />

Consider the case if the smallest possible negative value of type long. This value,<br />

9223372036854775808L, is allowed only as an operand of the unary minus operator<br />

(§3.10.1). <strong>The</strong>refore, enclosing it in parentheses, as in -(9223372036854775808L)<br />

causes a compile time error.<br />

In particular, the presence or absence of parentheses around an expression<br />

does not (except for the case noted above) affect in any way:<br />

• the choice of value set (§4.2.3) for the value of an expression of type float or<br />

double.<br />

• whether a variable is definitely assigned, definitely assigned when true, definitely<br />

assigned when false, definitely unassigned, definitely unassigned when<br />

true, or definitely unassigned when false (§16).<br />

15.9 Class Instance Creation Expressions<br />

And now a new object took possession of my soul.<br />

A Tale of the Ragged Mountains<br />

A class instance creation expression is used to create new objects that are<br />

instances of classes.<br />

ClassInstanceCreationExpression:<br />

new TypeArgumentsopt ClassOrInterfaceType ( ArgumentListopt )<br />

ClassBodyopt<br />

Primary. new TypeArgumentsopt Identifier TypeArgumentsopt (<br />

DRAFT<br />

ArgumentList opt ) ClassBody opt<br />

ArgumentList:<br />

Expression<br />

ArgumentList , Expression<br />

A class instance creation expression specifies a class to be instantiated, possibly<br />

followed by type arguments (if the class being instantiated is generic (§8.1.2)),<br />

followed by (a possibly empty) list of actual value arguments to the constructor. It<br />

is also possible to pass explicit type arguments to the constructor itself (if it is a<br />

423

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

Saved successfully!

Ooh no, something went wrong!