Reprint Light Annotated Source: http://blog.csdn.net/ns_code/article/details/35564663
The Java Collection Toolkit is located under the Java.util package and includes a very much used data structure, such as arrays, lists, stacks, queues, collections, hash tables, and so on. The Learning Java Collection Framework can be broadly divided into the following five parts: list lists, set sets, map mappings, iterators (Iterator, enumeration), tool classes (Arrays, collections).
The overall framework for the Java Collection class is as follows:
It can be seen that the collection class is divided into two major categories: collection and map.
Collection is a list, set and other sets of highly abstracted interface, it includes the basic operation of these sets, it is mainly divided into two parts: list and set.
The list interface typically represents a listing (arrays, queues, linked lists, stacks, and so on). The elements can be repeated. The implementation classes are often used for ArrayList and LinkedList. There are also vectors that are not used frequently.
In addition, LinkedList implements the queue interface, so it can also be used as a queue.
A set interface typically represents a collection. The elements differ in meaning and repetition (guaranteed by hashcode and the Equals function), often using implementation classes with HashSet and TreeSet. The hashset is implemented through the HashMap in the map, and TreeSet is achieved through the TREEMAP in the map.
Other than that. The TreeSet also implements the SortedSet interface. So it's an ordered set (the elements in the collection implement the comparable interface and overwrite the Compartor function).
We see that abstract classes Abstractcollection, Abstractlist, and Abstractset respectively implement the collection, list, and set interfaces, which is the very many adapter design patterns used in the Java collection framework, Using these abstract classes to implement interfaces, implement several or all of the methods in an interface in an abstract class, so that some of the following classes simply inherit the abstract class directly. and implement the method you need, instead of implementing all the abstract methods in the interface.
Map is a mapping interface in which each element is a Key-value key-value pair. The same abstract class Abstractmap implements most of the functions in the map interface through the adapter pattern. TreeMap, HashMap, Weakhashmap and other implementation classes are implemented through inheritance Abstractmap. Other than that. The infrequently used Hashtable directly implements the map interface, and the vector is the collection class introduced by JDK1.0.
iterator is an iterator that iterates through the collection (the map cannot be traversed.) Just to traverse Collection), the collection implementation class implements the Iterator () function, which returns a iterator object to iterate through the collection. Listiterator is designed to traverse the list. While enumeration is JDK1.0, the effect is the same as iterator. But it has less function than iterator. It can only be used again in Hashtable, vectors, and stacks.
Arrays and collections are the two tool classes used to manipulate arrays and collections, such as a large number of calls to the Arrays.copyof () method in ArrayList and vectors. There are very many static methods in collections that can return the synchronized version number of each collection class, the version number of thread-safe, of course, assuming a thread-safe binding class. Preferred concurrent the corresponding collection class under the concurrent package.
Java Collection source code anatomy Java Collection Framework