Section 7.2 Arrays

• An array is a group of variables (called elements or components; p. 245) containing values that all have the same type. Arrays are objects, so they’re considered reference types.

• A program refers to any one of an array’s elements with an array-access expression (p. 245) that includes the name of the array followed by the index of the particular element in square brackets ([]; p. 245).

• The first element in every array has index zero (p. 245) and is sometimes called the zeroth element.

• An index must be a nonnegative integer. A program can use an expression as an index.

• An array object knows its own length and stores this information in a length instance variable (p. 246).

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.