Arrays of Objects
Explore the concept of arrays of objects in Java, focusing on how arrays hold references to objects rather than the objects themselves. Understand the process of declaring, instantiating, and populating arrays with custom objects using loops, and clarify the distinction between creating an array and creating objects within the array.
We'll cover the following...
We'll cover the following...
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 ...