Motivation

In this lesson, we look at a simple problem where the solution needs a Java array.

Scenario: Calculating deviations from an average

Imagine a grade-school class during an arithmetic lesson. The teacher has planned an exercise using a calculator. She will announce ten numbers, and each student is to find the numbers’ sum. After that, she has some other calculations planned.

The twins, Vandee and Vander—Dee and Der to their friends—are anxious to show off their skills. As the teacher announces each of the ten numbers, the students key each one into their calculators. Dee likes to keep track of everything, so she carefully writes the number in her notebook before keying it into her calculator. Der, on the other hand, immediately enters it ...