Search⌘ K
AI Features

Motivation

Explore the motivation behind using arrays in Java by examining a practical example involving averages and deviations. Understand how arrays help efficiently store multiple values, enabling computation beyond simple sums, and why they are more practical than using many individual variables or re-entering data.

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 ...