Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, tutorials, and more.

In Java you can use an array to group primitives or objects of the same type. The entities belonging to an array is called the elements or components of the array. In this chapter you will learn how to create, initialize and iterate over an array as well as manipulate its elements. This chapter also features thejava.util.Arraysandjava.util.ArrayListclasses.

5.1 Array Overview

In the background, every time you create an array, the compiler creates an object which allows you to:

get the number of elements in the array through thelengthfield. The length or size of an array is the number of elements in it.

access each element by specifying an index. This indexing is zero-based. Index 0 refers to the first element, 1 to the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.