2.3.2 How to Represent Lists in an Object Diagram

For this example we will be using the code below.

As of line 82, a List of Food items exists and a Food object exists, but nothing has been added to the list yet.

Which will look like this in an object diagram:

When line 82 executes, a reference to the Cheetah Chips object will need to be made from the Foods field to the Food object.

Which will look like this:

As of line 90, the food variable has been overwritten with the Meatloaf object but has not been added to the list yet.

Once line 90 executes, the Meatloaf is added to the list and the object diagram will look like this:

And Once line 92 executes, the Monkey Tail will be added to the list...

...and the object diagram will look like this: