Example
This example creates three objects of class Personnel (as featured in the example at
the end of Sect. 4.6 ) and uses the add method of class ArrayList to place the
objects into an ArrayList . It then employs a ‘for-each’ loop and the ‘get’ methods
of class Personnel to retrieve the data properties of the three objects.
We could use the same ArrayList object for sending objects out to the file and
for receiving them back from the file, but two ArrayList objects have been used
below simply to demonstrate beyond any doubt that the values have been read back
in (and are not simply the original values, still held in the ArrayList object).