Card 08/ 08

RecapDifficulty: Intermediate1 min

Recap: Arrays

Fixed at creation, filled with defaults, indexed from zero, and never able to grow, with where each was.

Arrays come down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
One variable, a fixed length, one element type, all decided at creationJava Arrays: A Fixed Number of Values Under One Name
Declare, allocate, fill; every slot starts at its type's defaultCreating an Array: Declare, Allocate and Fill
The index is an offset, so the last one is length - 1Zero-Based Indexes Example: Why the Last of Seven Is Index 6
array.length, string.length(), collection.size()length vs length() vs size()
Arrays never grow; Arrays.copyOf makes a new one and copiesWhy a Java Array Cannot Grow

An array is a fixed run of slots, and every surprise in this topic comes from that one fact: the offset, the exception, and the copy you have to make to add anything.