CHAPTER 49B — Arrays of Objects and Linear Search

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/28/99; revised: 01/24/00, 07/20/02, 05/30/03, 02/03/06, 06/02/06

CHAPTER 49B — Arrays of Objects
and Linear Search

All the elements of an array must be of the same type. So far in these notes, the elements have been primitive types. However, an array can be made with elements of any data type, including object references. This chapter discusses arrays of object references.

Chapter Topics:

  • Arrays of object references
  • Arrays of String references
  • Linear search of an array
  • Phone directory application

A program often needs to search through an array to find a particular item. This chapter explains linear search, an algorithm for doing this.

QUESTION 1:

What does this statement do?

String str;