The list data type is similar to the array we just looked at. The list stores its objects in buckets but does not impose a fixed number of buckets. Once created, it is empty and can grow as you add additional objects to it. Consider the huge egg provider, Acme Egg Company. They have thousands of chickens laying eggs.
Acme cannot determine in advance how many eggs will be produced by their chickens. This makes the unbounded list container ideal for this scenario. Not surprisingly, the List itself is an object that stores your objects. The list contains an arrangement of objects you have added. As you saw in the video, there are two types:
ordered, meaning that which spot each element is placed on the list matters.
unordered, meaning that you group these items together, but it doesn't matter which one comes first, last, or fifteenth.
You can access a bucket in any particular position in the list. You can also insert into or remove an object at any particular position. The size of your list can grow/shrink in real time as objects are added and removed. It may also contain duplicates if you wish.
Try it out for yourself
Do you think Acme should use ordered or unordered lists for its eggs?
Brainstorm a few real-world groups of objects that would be useful to put in a list. Decide whether ordered or unordered lists would be better for each one of your groups of objects.
List is an ordered container of objects.
List size is dynamic and can become bigger or smaller according to your needs.