Section 7.3 Declaring and Creating Arrays

• To create an array object, specify the array’s element type and the number of elements as part of an array-creation expression (p. 246) that uses keyword new.

• When an array is created, each element receives a default value—zero for numeric primitive-type elements, false for boolean elements and null for references.

• In an array declaration, the type and the square brackets can be combined at the beginning of the declaration to indicate that all the identifiers in the declaration are array variables.

• Every element of a primitive-type array contains a variable of the array’s declared type. Every element of a reference-type array is a reference to an object of the array’s declared type.

Get Java™ How To Program (Early Objects), Tenth 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.