An array is a row of typed cells under one name, numbered from 0 — visit any cell instantly by its index.
1 A row of boxes
An array stores many values of ONE type under a single name, numbered from 0.
2 Create with new
int[] scores = new int[5] makes 5 cells in one block — all starting at 0.
3 Index access
scores[0] reads the first cell; scores.length is how many cells exist.
4 Loop through it
for (int i = 0; i < scores.length; i++) visits every cell in order.
Many values, one name
A row of boxes1An array stores many values of ONE type under a single name, numbered from 0. Create with new2int[] scores = new int[5] makes 5 cells in one block — all starting at 0. Index access3scores[0] reads the first cell; scores.length is how many cells exist.
Loop through it4for (int i = 0; i < scores.length; i++) visits every cell in order. 4 building blocks make up Many values, one name
Press Run to walk an array through its whole life, from declaration to iteration.
Press play: three cells get values, then the for loop collects them into a total.
JVMThe JVM loads the Scores class into memory.
Memory
no variables yet — press play
Console
output appears as the program runs…
Search walks the array cell by cell — the loop guard and the match test are two diamonds working together.
process decision input / output start / end Click a term, then click its meaning to lock the pair.
5 conceptsTap a card to expand ?indexdrops into place
?scores.lengthdrops into place
?new int[5]drops into place
?scores[2]drops into place
?OutOfBoundsExceptiondrops into place
01An array holds many values of one type under a single name.
02Indexes start at 0 and run to length - 1 — going past throws ArrayIndexOutOfBoundsException.
03new int[5] creates the cells and fills them all with 0.
04A for loop from 0 to length - 1 is the standard way to visit every element.