Lecture 4
5
Containers
•Powerful tool for programming data structures
•Provides a library of container classes to “hold your objects”
•2 types of Containers:
–Collection: to hold a group of elements e.g., List, Set
–Map: a group of key-value object pairs. It helps to return “Set of keys, collection of values, set of pairs. Also works with multiple dimensions (i.e., map of maps).
•Iterators give you a better handle on containers and helps to iterate through all the elements. It can be used without any knowledge of how the collection is implemented.
•Collections API provides a few general purpose algorithms that operate on all containers.