CHAPTER 46 — Arrays

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to home page   go to next page

revised: 11/25/99, 01/23/00, 07/20/02, 05/27/03, 01/29/06, 06/02/06

CHAPTER 46 — Arrays

Most real-world programs handle vast amounts of data. Fortunately, the data usually can be organized and processed systematically. Arrays or similar structures are almost always used for this. When data is organized into arrays and processed with loops a relatively small program can handle a vast amount of data. This chapter discusses arrays and shows examples of how they work.

Chapter Topics:

  • The idea of arrays
  • Array declaration
  • Array declaration and construction
  • Using arrays
  • Automatic bounds checking
  • Initializer lists

QUESTION 1:

Say that you are writing a program that reads in 100 numbers for data. Would you like to declare 100 variables and write 100 input statements to read in the data?