Look at the frame chart above, first grab its trunk, i.e. collection and map.
1 collection is an interface that is a highly abstracted collection that contains the basic operations and properties of a collection.
The collection contains the list and set of the two major branches.
The list is an ordered queue, and each element has its index. The index value of the first element is 0.
The list implementation class has LinkedList, ArrayList, Vector, Stack.
Set is a collection that does not allow repeating elements.
The implementation class for set has Hastset and TreeSet. HashSet relies on HashMap, which is actually implemented through HashMap; TreeSet relies on treemap, which is actually implemented by TreeMap.
2 map is a mapping interface, which is a Key-value key-value pair. Each element in the map contains "one key" and "key corresponding to 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 dictionary, it implements the map interface.
ArrayList and Vector
From the overall architecture, you can see that both ArrayList and vectors implement the list interface.
The list is an ordered queue, and each element has its index. The index value of the first element is 0.
The list implementation class has LinkedList, ArrayList, Vector, Stack.
LinkedList is a doubly linked list that inherits from Abstractsequentiallist. It can also be manipulated as a stack, queue, or double-ended queue.
The LinkedList implements the List interface and can queue operations on it.
LinkedList implements the Deque interface, which means that linkedlist can be used as a double-ended queue.
LinkedList implements the Cloneable interface, which covers the function clone () and can be cloned.
The LinkedList implements the Java.io.Serializable interface, which means that the LinkedList supports serialization and can be transmitted by serialization.
The LinkedList is non-synchronous.
****************
ArrayList is an array queue, which is equivalent to a dynamic array. Its capacity can grow dynamically compared to the array in Java. It inherits from the Abstractlist, implements the list, randomaccess, cloneable, java.io.Serializable these interfaces.
ArrayList inherits the Abstractlist and implements the list. It is an array queue that provides related additions, deletions, modifications, and traversal functions.
The ArrayList implements the Randmoaccess interface, which provides a random access function. Randmoaccess is used in Java to be implemented by the list, providing quick access to the list. In the ArrayList, we can quickly get the element object by the ordinal of the element, which is fast random access. Later, we compare the efficiency of the list's "Fast Random Access" and "access via iterator iterators".
ArrayList implements the Cloneable interface, which covers the function clone () and can be cloned.
The ArrayList implements the Java.io.Serializable interface, which means that the ArrayList supports serialization and can be transmitted by serialization.
******************
Vectors are vector queues, which are classes added by the JDK1.0 version. Inherits from Abstractlist, implements the list, randomaccess, cloneable these interfaces.
The Vector inherits the Abstractlist and implements the list; therefore, it is a queue that supports related additions, deletions, modifications, and traversal functions.
Vector implements the Randmoaccess interface, which provides a random access function. Randmoaccess is used in Java to be implemented by the list, providing quick access to the list. In vector, we can get the element object quickly by the ordinal of the element, which is fast random access.
Vector implements the Cloneable interface, which is the implementation of the Clone () function. It can be cloned.
******************
Stack is a stack. Its characteristics are: Advanced post-Exit (FILO, first in the last out).
The stack in the Java Toolkit is inherited from vectors (vector queues), since vectors are implemented by arrays, which means that stacks are also implemented through arrays, not linked lists. Of course, we can also use LinkedList as a stack! In the "vector detail of the Java Collection series 06 (source parsing) and usage examples", the data structure of the vector has been described in detail, and the data structure of the stack is no longer explained.
Unlike ArrayList, the operations in a vector are thread-safe.
The difference between ArrayList and vectors is that:
1 on the expansion, the ArrayList becomes (150%+1), the vector becomes (200%).
2Arraylist is not thread-safe, and vectors are thread-safe;
HashMap and HashSet
1HASHMAP implementation is the map interface, HashSet implementation is the set interface;
2HashMap storage is (key,value), Hastset only store a key, in fact, it is more accurate to store a (key,o), O is the hashset of an object-type member variable;
The essence of HashSet is a collection of "No duplicate elements", which is implemented through HashMap. The hashset contains a "member variable of type HashMap" Map,hashset operation function, which is actually implemented by map.
3 When adding elements, HashMap uses put (key,value), HashSet uses Add (key);
Both are not thread-safe.
Neither will have duplicate elements. What do you mean by repetition? is equal, as to what is equal in the set class can be seen:
About Hashcode and equals
HashMap and Hashtable
1HashMap is non-synchronous, while Hashtable is synchronous;
Both the key and value of 2HASHMAP are also null, and the key,value of Hashtable cannot be null;
Resources:
Http://www.cnblogs.com/wanlipeng/archive/2010/10/21/1857791.html
Http://www.cnblogs.com/skywang12345/p/3308498.html
The second blog is a directory of related articles in the Java collection, this note has repeatedly quoted the contents of the article, here is only a list of directories, we must go to see. The author analyzed the collection class very thoroughly.
The difference and connection between arraylist,vector,hashmap,hashset,hashtable