Java collection is a Java-provided toolkit that contains commonly used data structures: collections, lists, queues, stacks, arrays, mappings, and so on. Java Collection Toolkit location is java.util.*
Java collections can be divided into 4 main parts: List List, set set, map Map, tool class (iterator iterator, enumeration enum class, arrays and collections),.
Java Collection Toolkit framework diagram (as follows):
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/
General Description:
Looking at the frame above, first grab its trunk, collection and map.
The 1 collection is an interface, a highly abstracted set that contains the basic operations and attributes of the collection.
collection contains both the list and set branches.
The list is an ordered queue, and each element has its index. The index value of the first element is 0.
The implementation class of list has LinkedList, ArrayList, Vector, Stack.
Set is a collection that does not allow duplicate elements.
The implementation class for set has Hastset and TreeSet. HashSet relies on HashMap, which is actually implemented through HASHMAP, and TreeSet relies on treemap, which is actually implemented through TREEMAP.
The 2 map is a mapping interface, that is, a Key-value key value pair. Each element in the map contains "one key" and "key corresponding value".
Abstractmap is an abstract class that implements most of the APIs in the map interface. And Hashmap,treemap,weakhashmap are inherited from Abstractmap.
Although Hashtable inherits from the dictionary interface, it implements the map interface.
Next, look at the iterator. It is the tool that traverses the collection, that is, we usually traverse the collection through the iterator iterator. We say that collection relies on iterator because the collection implementation class implements the iterator () function and returns a iterator object.
The Listiterator is specifically designed to traverse the list.
Looking at enumeration, it is an abstract class introduced by JDK 1.0. function is the same as iterator, but the enumeration function is less than iterator. In the above block diagram, enumeration can only be used in Hashtable, vectors, and stack.
Finally, look at arrays and collections. They are two tool classes that manipulate arrays and collections.
With the overall framework above, we then analyze each class separately.