ABSTRACT

The Java Collection Library contains a long list of different collections each with benefits and liabilities in terms of flexibility, performance versus memory trade-offs, etc. However, we normally want to decouple our client code as much as possible from the implementation details of the data structures. One particular aspect is iteration. Iterating over the elements in a linked list (following the next reference) is radically different from iterating in an array (indexing). This creates a strong coupling between client code and the choice of data structure: if you change your mind and want to use a linked list instead of an array, you have to modify all the iterations.