10.6. Array Initializers
An array initializer may be specified in a declaration (§8.3, §9.3, §14.4), or as part of an array creation expression (§15.10), to create an array and provide some initial values.
ArrayInitializer: {
VariableInitializersopt ,
opt }
VariableInitializers: VariableInitializer VariableInitializers ,
VariableInitializer
The following is repeated from §8.3 to make the presentation here clearer:
VariableInitializer: Expression ArrayInitializer
An array initializer is written as a comma-separated list of expressions, enclosed by braces {
and }
.
A trailing comma may appear after the last expression in an array initializer and is ignored.
Each variable initializer must be assignment-compatible (§5.2) with the array’s ...
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.