Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 13. Collections > Concrete Collections

Concrete Collections

Rather than getting into more details about all the interfaces, we thought it would be helpful to first discuss the concrete data structures that the Java library supplies. Once we have thoroughly described the classes you might want to use, we will return to abstract considerations and see how the collections framework organizes these classes. Table 13–1 shows the collections in the Java library and briefly describes the purpose of each collection class. (For simplicity, we omit the thread-safe collections that will be discussed in Chapter 14.) All classes in Table 13–1 implement the Collection interface, with the exception of the classes with names ending in Map. Those classes implement the Map interface instead. We will discuss the Map interface in the section “Maps” on page 680.

Table 13–1. Concrete Collections in the Java Library
Collection TypeDescriptionSee Page
ArrayListAn indexed sequence that grows and shrinks dynamically668
LinkedListAn ordered sequence that allows efficient insertions and removal at any location659
ArrayDequeA double-ended queue that is implemented as a circular array678
HashSetAn unordered collection that rejects duplicates668
TreeSetA sorted set672
EnumSetA set of enumerated type values687
LinkedHashSetA set that remembers the order in which elements were inserted686
PriorityQueueA collection that allows efficient removal of the smallest element679
HashMapA data structure that stores key/value associations680
TreeMapA map in which the keys are sorted680
EnumMapA map in which the keys belong to an enumerated type687
LinkedHashMapA map that remembers the order in which entries were added686
WeakHashMapA map with values that can be reclaimed by the garbage collector if they are not used elsewhere685
IdentityHashMapA map with keys that are compared by ==, not equals688



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial