CHAPTER 47 — Common Array Algorithms

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, 12/03/99, 01/24/00, 07/20/02, 05/27/03, 06/02/06, 07/07/07

CHAPTER 47 — Common Array Algorithms

Line of boxes, vanishing into the horizon

An array that uses a single subscript is called a one dimensional array. This is because one index is used to access the values in the array. Its cells are like boxes lined up one after the other in a line. A two dimensional array requires two indexes to access values. Its cells are like boxes arranged into a rectangle. Arrays of even higher dimension are possible, although rarely used. This chapter discusses typical uses for one dimensional arrays.

Chapter Topics:

  • Arrays and counting loops
  • Enhanced for loop
  • The length of an array
  • Finding the maximum and minimum of an array of numbers
  • Finding the sum of the elements of an array
  • Computing the average of the elements of an array

QUESTION 1:

How (in general) could you print out every element of an array with 100 cells?