CHAPTER 48 — Arrays as Parameters

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

created: 11/25/98; revised: 04/21/99, 11/25/99, 01/24/00, 07/20/02, 05/28/03, 02/02/06

CHAPTER 48 — Arrays as Parameters

The last two chapters were about arrays. The example programs used a main() method which contained the arrays and did all the computing. This is not the way programs are usually written. Usually, arrays (and other forms of data) are manipulated by passing them as parameters to methods. Each method is like a "tool" that does something with an array. For example, there may be a method that finds the maximum element of an array, or a method that adds up all the elements in an array.

Chapter Topics:

  • Parameters of methods (review)
  • Arrays as parameters
  • Picture of array parameter passing
  • Primitive types as parameters

QUESTION 1:

(Review:) What is a parameter?