1 、---| Collection: Single-column collection
---| List: With storage order, repeatable
---| ArrayList: Array implementation, Find Fast, and delete slowly
Because it is an array implementation, the array is involved in the increment and delete
Add capacity, and copy elements. So slow. Arrays can be directly
Find by index, so faster to find
---| LinkedList: Linked list implementation, delete fast, find slow
As the list is implemented, it increases as long as the previous element is remembered from the
You can, when you delete, let the previous element remember the last dollar
elements, and the latter element remembers the previous element. The effect of such additions and deletions
Rate is high but the query requires one traversal, so the efficiency is low
---| Vector: Same principle as ArrayList, but thread-safe, slightly less efficient
Same as ArrayList implementation, but thread safety considerations
So the efficiency is slightly lower
---| The set interface is unordered and cannot be duplicated
---| HashSet thread is not secure and access speed is fast. The bottom layer is implemented by a hash table.
---| The TreeSet red-Haishi data structure, which by default naturally sorts the elements (String).
If two objects return a value of 0 at the time of comparison, then the element repeats.
2,---| The map interface maps the key to the object of the value. A map cannot contain duplicate keys, and each key can be mapped to at most one value.
---| HashMap is implemented with a hash table, so unordered
---| TreeMap can sort the health
---| Hashtable: The underlying is a hash table data structure, threads are synchronous, and cannot be stored as null keys, null values. Low efficiency, replaced by HashMap.
---| HashMap: The underlying is a hash table data structure that the thread is not synchronized and can be stored in a null key, null value. To guarantee the uniqueness of the key, you need to override the Hashcode method,
And the Equals method.
---| Linkedhashmap: The subclass is based on a hash table and is incorporated into the list. You can increase the efficiency by adding or deleting the Map collection.
---| TREEMAP: The bottom layer is a two-fork tree data structure. You can sort the keys in the map collection. You need to use comparable or comparator for comparison sorting.
return 0, to determine the uniqueness of the key.
3, if the call to remove before the call to next is not legal, will throw illegalstateexception;
4, note at the same time to rewrite the Equals method and Hashcode method, to use the ToString method to display the collection directly, you should pay attention to rewrite;
5 、----| Comparable
The CompareTo (Object o) element has its own comparative
----| Comparator
Compare (object O1, Object O2) to the container incoming comparer
TreeSet the two ways to sort the collection: one, to make the elements themselves comparable. That is, the element needs to implement the comparable interface, overriding the CompareTo method. This approach also acts as a natural ordering of elements
, or it can be called the default sort.
Second, let the container itself have a comparative, custom comparator. Requirements: When the element itself is not comparable, or the element itself has a comparison is not required.
Then only the container itself can have.
Defines a class that implements the comparator interface, overriding the Compare method. and passes the subclass object of the interface as a parameter to the constructor of the TreeSet collection.
When comparable comparison way, and comparator comparison way exist simultaneously, take comparator comparison mode as main.
6, the way to traverse the map:
All keys in the map collection are fetched into the set set.
Set<k> KeySet () returns the set set of all key objects
The value corresponding to the key is obtained by the Get method.
VALUES () to get all the values.
Collection<v> values () cannot get to the key object
The Map.entry object recommends using the Focus set<map.entry<k,v>> EntrySet () to package the key-value mappings in the Map collection into an object map.
The Entry object obtains its key and value through the Getkey,getvalue of the Map.entry object.
7, a task a process, a process can have multiple threads;
8, synchronization is a mechanism to prevent access to the same resource, resulting in deadlock or incorrect results; You can create a synchronous method, or you can use a synchronous code block;
9, Multi-threaded implementation: First, inherit the thread class, rewrite run (), when used to call Start ();
Second, the implementation of the Runable interface, rewrite run (), the use of his implementation of the class reference to the constructor method as a parameter;
2017/12/28-1 integrated and multi-threaded