Summary
This chapter introduced you to the Java collections framework, which is a very powerful tool within the Java language that can be used to store, sort, and filter data. The framework is massive and offers tools in the form of interfaces, classes, and methods, some of which are beyond the scope of this chapter. We have focused on Arrays
, Lists
, Sets
, Maps
, and Properties
. But there are others, such as queues and dequeues, that are worth exploring on your own.
Sets, like their mathematical equivalents, store unique copies of items. Lists are like arrays that can be extended endlessly and support duplicates. Maps are used when dealing with key-value pairs, something very common in contemporary computing, and do not support the use of two of the same keys. Properties work very much like HashMap
(a specific type of Map
) but offer some extra features, such as the listing of all their contents to streams, which simplifies the printing out of the contents of a list.
Some of the...