Arrays of Objects

In this lesson, we investigate how Java stores objects in an array.

What is an array of objects?

While the entries in an array of primitive values are actually those values, the entries in an array of objects are only references to the objects, not the objects themselves. So even though our discussions and illustrations often will save space by depicting arrays as if they contained objects, they do not. The figure given below shows an array of strings in two different ways. The first drawing is how we usually will show such an array, while the second one illustrates that the array really contains references to the strings, which are in fact objects.

Get hands-on with 1200+ tech skills courses.