The Java Collection Toolkit, located under the Java.util package, contains a number of commonly used data structures, such as arrays, lists, stacks, queues, collections, hash tables, and so on. The Learning Java Collection Framework can be roughly divided into five parts: List List, set set, map map, iterator (iterator, enumeration), tool Class (Arrays, Collections).
The overall framework of the Java Collection class is as follows:
As can be seen from the above figure, the collection class is divided into two main categories: collection and map.
Collection is a highly abstracted interface of the list, set, and so on, which contains the basic operations of these sets, which are divided into two main parts: list and set.
The list interface usually represents a listing (arrays, queues, lists, stacks, etc.) in which elements can be duplicated, common implementation classes are ArrayList and LinkedList, and vectors that are not commonly used. In addition, LinkedList implements the queue interface and can also be used as a queue.
This column more highlights: http://www.bianceng.cn/Programming/Java/
The set interface usually represents a collection in which elements are not allowed to be duplicated (guaranteed by the hashcode and equals functions), and the common implementation classes have HashSet and Treeset,hashset are implemented through HASHMAP in the map. The TreeSet is implemented through the TREEMAP in the map. In addition, TreeSet implements the SortedSet interface, so it is an ordered collection (the elements in the collection implement the comparable interface and overwrite the Compartor function).
We see that the abstract class abstractcollection, Abstractlist, and Abstractset implement the collection, list, and set interfaces, which are the many adapter design patterns used in the Java collection framework, Use these abstract classes to implement interfaces that implement some or all of the methods in an interface in an abstract class, so that some of the following classes simply inherit the abstract class and implement the methods that you need without implementing all the abstract methods in the interface.
Map is a mapping interface in which each element is a Key-value key value pair, and the same abstract class Abstractmap implements most of the functions in the map interface through the adapter pattern, TreeMap, HashMap, The implementation classes such as Weakhashmap are implemented by inheriting Abstractmap, in addition, the hashtable of the map interface is implemented directly by the less commonly used, and vector is the collection class introduced by JDK1.0.
Iterator is an iterator that iterates through the collection (cannot traverse the map, only to traverse the collection), and the collection implementation class implements the iterator () function, which returns a iterator object to traverse the collection. Listiterator is specifically used to traverse the list. And enumeration is introduced in JDK1.0, the role is the same as iterator, but its function is less than iterator, it can only be used in Hashtable, vector and stack.
Arrays and collections are the two tool classes used to manipulate arrays and collections, such as the Arrays.copyof () method, which is called heavily in ArrayList and vectors. In collections, there are many static methods to return the synchronized version of each collection class, which is a thread-safe version, and of course, if you want to use the thread-safe binding class, you prefer to concurrent the corresponding collection class under the concurrent package.