Introduction: Arrays

This chapter begins with its prerequisites, learning objectives, and overview.

We'll cover the following

Prerequisites

Objectives

After completing this chapter, you should be able to:

  • Declare and allocate a one-dimensional array
  • Initialize the elements in an array
  • Write a loop that searches an array for a given value, the smallest value, or the largest value
  • Define methods that accept an entire array as an argument
  • Define methods that return an array
  • Copy the entries from one array to another
  • Test whether two arrays are equal

Overview

Programmers often must keep track of a group of items. These items might be as simple as primitive values or as complex as large objects. In most programming languages, the underlying construct that allows us to gather such items together is called an array, and Java is no exception. This chapter will introduce this language feature and show you how to use it to perform various tasks. As we will see, arrays enable us to manipulate large groups of data concisely.

Get hands-on with 1400+ tech skills courses.