An array stores a fixed number of elements of one declared type. Its length field tells you how many; the valid indices run from zero through length minus one. Check an empty array before reading its first element. The enhanced for loop visits values directly, while an indexed loop is useful when you need to write an output position.
An array variable holds a reference. Assigning it to another variable gives both names access to the same array, so a change through either name is visible through the other. Allocate a new array when you need an independent copy. Java also supports arrays of arrays, whose rows may have different lengths. Traverse each row's own values instead of assuming a rectangle. Empty outer arrays and empty rows are normal inputs in this lesson.