aggregate
1. Meaning
- A collection is a series of classes provided by the Java API itself, which can be used to dynamically store multiple objects (a collection can only store objects)
- Differences between sets and arrays:
- aggregate
- A collection is a sequence of variable sizes
- Element types can be unrestricted
- As long as it is a reference type
- A collection cannot hold basic data types, but it can hold wrapper classes of basic data types
- Array:
- Fixed array length
- Arrays can store basic data types and reference types
- aggregate
- Collection classes all support generics, which is a data security usage
2 set frame diagram
The collection framework of Java can be divided into two families as a whole
- Collection (Interface) family. All children and grandchildren under this interface store a single object. Add(s)
- Map (Interface) family. All children and grandchildren under the interface store data in the form of key value (key value pair). Put (key, value)
There are also three branches, all serving the above two large families
- Iterator family. Designed to traverse the Collection interface and its subclasses
- Comparator is used to compare objects when storing objects in a collection
- Collection s is a tool class. Note: the class name with an s generally indicates the tool class. It provides N static methods to compare Collections
List: ordered (consistent with the entered order) and can be repeated with subscripts
Set: out of order (inconsistent with the input order, not random, but determined by hash value + hash algorithm), can not be repeated without subscript
3.Collection family
Common methods:
- int size(); Returns the elements in this Collection
- boolean i is Empty(); judge whether this collection contains elements
- boolean contains (Object obj); judge whether the collection contains the specified element.
- boolean contains (Collection c); judge whether this collection contains all elements in the specified collection
- boolean add (Object element); add an element to this collection
- boolean addAll (Collection c); adds all elements in the specified collection to this collection
- boolean remove (Object element); removes the specified element from this collection
- boolean removeAll (Collection c); removes all elements in this collection that are also contained in the specified collection
- void clear(); remove all elements in the collection
- Boolean retain all (Collection c); only those elements in this collection that are also included in the specified collection are retained
- Iterator iterator(); returns the iterator that iterates over the elements of this collection
- Object[] toArray(); convert this collection into an array
3.1 List interface
Usage scenario:
ArrayList [key]: implementation of array structure, fast query, slow addition and deletion, and continuous space development; JDK1. Version 2, fast running efficiency and unsafe thread
LinkedList: implementation of linked list structure, fast addition and deletion, slow query, and no continuous space; JDK1. Version 2, slow running efficiency, queue mode, stack mode, thread unsafe
Vector: array structure implementation, fast query, full addition and deletion; JDK1. Version 0, which is slow and thread safe, is discarded. Version 1.2 is added to the list interface
Stack: deprecated, thread safe
Features: orderly and repeatable (because many methods for subscript operation are added to the List interface)
There are four traversal methods:
- for loop
- foreach loop
- Iterator iterator loop
- ListIterator iterator loop
Iterator recycling steps:
- Get the iterator object - "use the hashNext() method in the iterator object to determine whether there is an object that can be iterated in the while loop" - output the next element returned by the iterator (iterator object. Next())
Unique iterator in the list interface: ListIterator iterator
//Traversal ------- ListIterator iterator ListIterator<String> listIterator=list.listIterator();//Gets the ListIterator iterator object while(listIterator.hashNext()){//Determine whether there are objects that can be iterated String e=listIterator.next();//Returns the next element System.out.println(e); }
3.1. 0 new method of list interface compared with Collection interface
Several new practical methods:
- public Object get(int index) / / returns the elements in the list according to the subscript
- public Object add(int index,Object element) / / insert the specified element at the specified position in the list, and move the current element (if any) and all subsequent elements to the right
- public Object set(int index, Object element) / / replace the element at the specified position with the specified element
- public Object remove(int index) / / remove the element at the specified position in the table
- Note: the elements in the list collection are indexed from 0, just like the elements in the array
3.1.1 ArrayList:
public class Test{ public static void main(Strin[] args){ ArrayList list=new ArrayList(); //Add element list.add("character string"); list.add(100);//Integer.valueOf(100); list.add(123.123);//Double.valuOf(123.123); } }
3.1.2 LinkedList
Unique features of LinkedList:
-
Queue mode: first in first out
-
public class Test{ public static void main(String [] args){ LinkedList<String> list=new LinkedList<>(); list.add("aaa"); list.add("bbb"); list.add("ccc"); while(!list.isEmpty){ //Delete the first element and return String element=list.removeFirst(); System.out.println(element); } System.out.println("Number of elements in the collection"+list.size()); } }
. The removeFirst() method indicates that the queue mode is first in first out
-
-
Stack mode: first in and last out
-
Similarly: the first in and last out of stack mode is the first out The removeFirst method is modified to removeLast() method
-
Knowledge points: use LinkedList method + generics
Generics: data security practices that specify what data types a collection should store
The code implements the methods of the list interface, that is, all traversal methods:
public class Test01{ public static void main(String [] args){ /** Knowledge points: use Linkedlist method + generics Generic: a data security practice that specifies what data types a collection should store */ LinkedList<String> list=new LinkedList<>(); //Add element list.add("Rongxi"); list.add("To make a living"); list.add("Heart"); //Gets the number of elements int size=list.size(); System.out.println("Get the number of elements:"+size); //Sets the element on the specified subscript list.set(0,"Xiao Zheng"); //Gets the element on the specified subscript String element=list.get(0); System.out.println("Gets the element with the specified subscript:"+element); //Inserts an element at the specified subscript list.add(1,"Xiao Zhang"); LinkedList<String> newlist1=new LinkedList<>(); Collections.addAll(newlist,"aaa","bbb","ccc");//Batch addition using collection tools list.addAll(newlist1);//Adds all elements in the new collection to the end of the specified collection LinkedList<String> newList2=new LinkedList<>(); Collections.addAll(newList2,"ddd","eee","fff");//Batch adding using collection tool classes list.addAll(3,newList2);//Adds all elements in the new collection to the specified subscript on the specified collection //Clear the list of all elements in the collection clear(); System.out.println("Determine whether the collection contains an element"+list.contains("Xiao Zhang")); LinkedList<String> newList3=new LinkedList<>(); Collections.addAll(newList3,"eee","fff","ddd");//Batch adding using collection tool classes System.out.println("Judge whether the set contains all the elements in a set:"+list.containsAll(newList3)); int index=list.indexOf("To make a living"); System.out.println("Gets the subscript of the element in the collection"+index); boolean empty =list.isEmpty();//If there are elements -- - false if there are no elements -- - true System.out.prinntln("Determine whether the element does not exist in the collection:"+empty);//false //delete list.remove(3);//Delete element by subscript list.remove("eee");//Delete element by element //Delete --- intersection LinkedList<String> newList4=new linkedList<>(); Collections.addAll(newList4,"fff","aaa","bbb");//Use the tool class of the collection for batch addition list.addAll(newList4); //Reserved set LinkedList<String> newList5=new LinkedList<>(); Collections.addAll(newList,"Rongxi","Xiaoya","Xiaohui"); list.retainAll(newList5); //Replaces the element on the specified subscript list.set(4,"Yi'er"); //Gets the elements from the start subscript to the end subscript (not included), and returns a new collection List<String> subList=list.subList(1,5); //Convert collection to array Object[] array=subList.toArray(); System.out.println(Arrays.toString(array)); System.out.println("-----------"); //Traversal ----- for for(int i=0;i<list.size();i++){ System.out.println(list.get(i)); } System.out.println("-----------"); //Traversal -- foreach for(String e:list){ System.out.println(e); } System.out.println("--------------"); //Traversal ----- Iterator iterator Iterator<String> it=list.iterator();//Gets the Iterator iterator object while(it.hashNext()){//Determine whether there are elements that can be iterated String e=it.next();//Returns the next element System.out.println(e); } System.out.println("-------------"); //Traversal ------- ListIterator iterator ListIterator<String> listIterator=list.listIterator();//Gets the ListIterator iterator object while(listIterator.hashNext()){//Determine whether there are objects that can be iterated String e=listIterator.next();//Returns the next element System.out.println(e); } } }
3.1.3 Vector
Understand: Vector is a collection class at the veteran level, from jdk1 0, jdk1 2. The concept of collection framework was introduced at the beginning. Considering that many programmers used to use Vector at that time, Vector also implemented the List interface, so it was retained
Vector's unique old method before implementing the List interface:
public class Test{ public static void main(String [] args){ Verctor<String> v=new Verctor<>(); //Add element v.add(); //Delete element v.removeElement();//You can delete an element by subscript or by element //ergodic Elemeration<String> element=v.elements(); while(elements.hasMoreElements()){ String nextElement =element.nextElement(); System.out.println(nextElement); } } }
Features: there is an older set of traversal methods
Similarly, Vector also has all methods of the list interface and traversal methods, because they all inherit the methods of the parent class list
3.1.4 Stack
Features: stack mode - first in and last out
public class Test{ public static void main(String[] args){ Stack<String> stack=new Stack<>(); //Add an element and push the element into the top of the stack stack.push("Rong 1"); stack.push("Rong 2"); stack.push("Rong 3"); stack.push("Rong 4"); System.out.println("Distance from stack top(Start with 1): "+stack.search("Rong 2")); while(!stack.empty()){ //Gets the first element at the top of the stack and returns //String element=stack.peek(); //Delete the first element at the top of the stack and return String element=stack.pop(); System.out.println(element); } System.out.println(stack.size()); } }
Similarly, stack also inherits from the parent class list interface, so it can also implement all methods of list
3.2 Set interface
Features: disordered and non repeatable
Usage scenario:
HashSet [key]: Based on HashCode, the implementation is not repeated. When the hash codes stored in the elements are the same,
It will call = = or equls to confirm, and the result is true to reject saving
De duplication + order, thread unsafe
LinkedHashSet: a HashSet implemented by a linked list. It is stored according to the linked list to retain the insertion order of elements,
The header interpolation is used to avoid the hash loopback problem.
De duplication + order, thread unsafe
TreeSet: 1. Non repetition of elements based on sorting order 2 The SortedSet interface is implemented to automatically sort the set elements
3. The type of the element object must implement the Comparable interface and specify the collation
4. Determine whether it is a duplicate element through the CompareTo method
5. De duplication + disorder, thread unsafe
3.2.1 HashSet
Features: de duplication + disorder
Note: in HashSet, disorder does not represent randomness, but the order of hash value + hash algorithm is used
public class Test01{ public static void main(String[] args){ /** Knowledge points: using HashSet method Features: de duplication + disorder */ HashSet<String> set=new HashSet<>(); //add to set.add("Rong 1"); set.add("Rong 2"); set.add("Rong 3"); set.add("Rong 5"); //Gets the number of elements int size=set.size(); System.out.println("Number of elements obtained:"+size); HashSet<String> newSet1=new HashSet<>(); Collections.addAll(newSet1,"To make a living","Heart"); set.addAll(newSet1);//Adds all elements in the new collection to the end of the specified collection //Empty all elements in the collection //set.clear(); System.out.println("Determine whether the collection contains an element"+set.contains("Rong 2")); HashSet<String> newSet2=new HashSet<>(); Collections.addAll(newSet2,"Rongyu","Rongxin"); System.out.println("Determine whether the collection contains an element:"+set.containsAll(newSet2)); boolean empty=set.isEmpty();//With element -- false without element -- true System.out.println("Determine whether there are no elements in the collection:"+empty); //delete set.remove("Rong 2"); //Delete intersection HashSet<String> newSet3=new HashSet<>(); Collections.addAll(newSet3,"Rong 5","Heart","Rongxin"); set.removeAll(newSet3); //Preserve intersection HashSet<String> newSet4=new HashSet<>(); Collections.addAll(newSet4,"Rong 1","Rongyu","To make a living"); set.retainAll(newSet4); //Convert collection to array Object [] array=set.toArray(); System.out.println(Arrays.toString(array)); System.out.println("---------------"); //Traversal ----- foreach for(String element:set){ System.out.println(element); } System.out.println("--------------"); //Traversal - Iterator iterator Iterator<String> it=set.iterator();//Gets the Iterator iterator object while(it.hasNext()){//Determine whether there are elements that can be iterated String e=it.next();//Returns the next element System.out.println(e); } } }
3.2.2 LinkedHashSet
It is the same as the HashSet method, except that the LinkedHashSet constructs a new hash chain and uses the node to find the address for one-way linked list. The underlying principle is to call the HashMap.
Similarly: LinkedHashSet is also an inherited set method. You can use the set method the same as the HashSet above
3.2.3 TreeSet
Similarly, TreeSet can also use all methods of set
Features: TreeSet can sort
- Integer packing data type: numeric sort
- Save string type: Dictionary sort
public class Test{ public static void main(String[] args){ /** Knowledge points: TreeSet sorting Requirements: create two TreeSet objects, save Integer and String respectively, and sort them TreeSet Save Integer: numeric sort TreeSET Save String: Dictionary sort */ TreeSet<Integer> set1=new TreeSet<>(); //Add element set1.add(5);//Integer.valueOf(5); set1.add(1);//Integer.valueOf(1); set1.add(3);//Integer.valueOf(3); set1.add(4);//Integer.valueOf(4); set1.add(2);//Integer.valueOf(2); //Traversal ----- foreach for(Integer integer:set1){ System.out.println(integer); } TreeSet<String> set2=new TreeSet<>(); set2.add("c"); set2.add("d"); set2.add("a"); set2.add("b"); for(String string:set2){ System.out.println(string); } } }
Built in comparator: there are two ways to implement the comparable override compareTo method for comparison
- return this. Subtract o. the order of the attributes to be compared. Backward subtraction
- return type compare(this. Attributes to be compared, o. attributes to be compared) order. Exchange positions if reverse order is required
External Comparator: create a Comparator method in the brackets of the new TreeSet and override compare. The comparison method is the same as that of the built-in Comparator. Scope: used when the built-in Comparator cannot meet the requirements, but the rules of the built-in Comparator cannot be changed.. In the underlying source code, the external Comparator is preferred. If there is no external Comparator, the built-in Comparator is called. Therefore, the priority of the external Comparator is higher than that of the built-in Comparator. Source code verification:
Comparator<? super K> cpr = comparator; if (cpr != null) {//If the external comparator is not used, if it is empty, it will not enter the external comparator. It is one of two ways. If it enters the external comparator, it will not enter the built-in comparator, so the external comparator takes precedence over the built-in comparator do { parent = t; cmp = cpr.compare(key, t.key); if (cmp < 0) t = t.left; else if (cmp > 0) t = t.right; else return t.setValue(value); } while (t != null); } else { if (key == null) throw new NullPointerException(); @SuppressWarnings("unchecked") Comparable<? super K> k = (Comparable<? super K>) key; do { parent = t; cmp = k.compareTo(t.key); if (cmp < 0) t = t.left; else if (cmp > 0) t = t.right; else return t.setValue(value); } while (t != null); }
Differences between list interface and set interface:
List interface: it has subscripts, the stored elements are orderly, and duplicate collection interfaces are allowed. It has a unique listIterator iterator
Set interface: elements without subscripts need not contain duplicate set interfaces
4 Map family
4.1 usage scenarios:
HashMap [key]: jdk1 Version 2, thread unsafe, fast running efficiency; null is allowed as key or value
Hashtable: JDK1. Version 0 is thread safe and runs slowly. null is not allowed as key or value.
Properties: subclass of Hashtable. Both key and value are required to be strings. It is usually used for reading configuration files.
TreeMap: implements SortedMap interface (sub interface of Map), which can automatically sort key s,
- key needs to implement the comparable interface, that is, implement the built-in comparator, and compare by rewriting the compareTO method,
- When the functions to be implemented by the key cannot be met by the built-in comparator, the built-in comparator cannot be modified. Because the built-in comparator can be used by others, the external comparator needs to be used to meet the conditions, that is, the comparator interface rewrites the compare method to sort the keys
4.2 methods used:
Method of map class implementation
-
. put() method: used to add elements
-
. clear() method: used to empty the collection
-
. containsKey() method: judge whether there is a key in this collection
-
. containsValue() method: judge whether there is a Value in this collection
-
Get the corresponding value through the key
- . get() method: get the corresponding value value through the key
- . getOrDefault() method: get the corresponding value value through key. If there is no such set in the set, add the default value
- . isEmpty(): judge whether there is no such element in the collection
-
. putAll() method: add all the elements in the new set to the map set
-
. putIfAbsent(key,value) method: add an element. If there is a key value, it will not be added, and return the set value. If there is no set, it will add the key value
-
Delete method remove():
- You can use the key value to delete the mapping relationship.
- You can also use key value pairs to delete mapping relationships
-
Modification / replacement method:
- . replace(): replace value with key
- . replace(key,value, replaced value): replace value through key value pairs
- . put(key,value): when adding an element, replace the value value with the same key
-
Number of set mapping relationships: size(): gets the number of in the collection
-
Get all values in the collection: values(): write in the print statement and output all values in the set
-
Traversal: ------ keyset(): Keyset() generates keyset = map keySet();
for(String key:keySet){
Integer value=map.get(key);// Get the corresponding value through the key
Write key+value in output}
4.3 HashMap
Features: HashMap key is unique, and value can be repeated. Store key value pairs, unordered
Note: disorder does not mean random. It is carried out according to the storage order
null keys are allowed, which is thread unsafe
4.4 LinkedHashMap
Features: the ConcurrentHashMap key is unique, and the value can be repeated
Store key value pairs in order. null keys are allowed. Threads are unsafe
//Traversal 1--keySet() //Traversal idea: extract all the keys in the LinkedHashMap and store them in the Set set. Traverse the Set set and take out the keys in turn to obtain the corresponding Value Set<String> keySet = map.keySet(); for (String key:keySet){ Integer value=map.get(key);//Get the corresponding value through the key System.out.println(key+"------"+value); } System.out.println("-----------------"); //Traversal 2---entrySet() //Traversal idea: put the key and value in the LinkedHashMap Set<Map.Entry<String, Integer>> entrySet = map.entrySet(); for (Map.Entry<String,Integer>entry:entrySet){ String key=entry.getKey(); Integer value = entry.getValue(); System.out.println(key+"-----"+value); }
4.5 ConcurrentHashMap
Stored key value pairs are out of order, null keys are not allowed, and thread safety (local locking, high efficiency)
ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<>(); map.put(null, "xx"); Set<Entry<Object,Object>> entrySet = map.entrySet(); for (Entry<Object, Object> entry : entrySet) { System.out.println(entry.getKey() + " -- " + entry.getValue()); }
4.6 TreeMap
Features: TreeMap is used to sort keys
The bottom layer of HashSet is implemented by HasMap. The elements stored in HashSet are stored in the location of HashMap key, because HashMap key cannot be repeated
The underlying layer of TreeSet is implemented by HasMap. The elements stored in TreeSet are stored in the location of treemap key, because treemap key is sorted
The use of built-in comparator and external comparator is also described in Treeset method, and the effect is the same. According to the requirements, the key value is sorted
4.7 Hashtable
Features: stored key value pairs are out of order, null keys are not allowed, thread safe (locked directly in the method, low efficiency), abandoned
Hashtable key is unique, and value can be repeated
//Traversal 1 - keySet() //Traversal idea: extract all the keys in the Hashtable and store them in the Set set. Traverse the Set set and take out the keys in turn to obtain the corresponding Value Set<String> keySet = map.keySet(); for (String key : keySet) { Integer value = map.get(key);//Get the corresponding value through the key System.out.println(key + " -- " + value); } System.out.println("--------------"); //Traversal 2 - entrySet() //Traversal idea: extract all the mapping relationships (entries) in the Hashtable and store them in the Set set. Traverse the Set set and take out the mapping relationships (entries) in turn to obtain the key and value in the mapping relationship Set<Entry<String, Integer>> entrySet = map.entrySet(); for (Entry<String, Integer> entry : entrySet) { String key = entry.getKey(); Integer value = entry.getValue(); System.out.println(key + " -- " + value); }
4.8 Properties
It is generally used to develop connection database and create one Properties file, enter the user and password of the database and the database connected to the database, and then create a file object in the class to load the configuration file and obtain the data of the configuration file
//Object to create profile Properties p=new Properties(); //Load the configuration file into the object p.load(Test01.class.getClassLoader().getResourceAsStream("DBConfig.properties")); //Get data in configuration file String username=p.getProperty("username"); String password=p.getProperty("password"); System.out.println(username+"-------"+password);
The difference between Collection and Map
Collection: add is used as the addition method. There are iterators for traversal, as well as for loops and foreach traversal
Map: use put as the addition method, no iterator for traversal, and use The entrySet() method traverses the foreach. It is used to store any key value pair (key – value). Key has no subscript, can not be repeated and is unique. Value has no subscript and can be repeated
ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<>(); map.put(null, "xx"); Set<Entry<Object,Object>> entrySet = map.entrySet(); for (Entry<Object, Object> entry : entrySet) { System.out.println(entry.getKey() + " -- " + entry.getValue()); }
5 generics
5.1 concept:
For parameterized and type safe collections, the types of collection elements must be consistent
5.2 features:
- You can check at compile time instead of throwing an exception at run time
- When accessing, type conversion (plug-in box) is not necessary
- References between different generics cannot be assigned to each other, and there is no polymorphism in generics
Meaning: data security practices
Generic qualification:
? Any type is OK
? extends A means that the element must be a class or a subclass of A
? super A means that the element must be a class or the parent of A
6 iterator
Meaning: traverse the data in the collection
Classification: Iterator and ListIterator
Difference between Iterator and ListIterator
Iterator: iterator that can be obtained by all implementation classes under the Collection interface. Elements can be deleted during traversal
ListIterator: iterators that can be obtained by all implementation classes under the List interface. You can delete, replace and add elements during traversal, specify subscripts to start traversal, and flashback traversal
7 comparator interface
Function: used when sorting
Classification:
Built in comparator: Comparable - compareTo()
External comparator: Comparator - compare()
Usage scenario:
Built in comparator: if an object wants to be stored in TreeSet and TreeMap, the class to which the object belongs must implement the built-in comparator
External comparator: when the built-in comparison rules do not meet the current requirements, but the built-in comparator rules cannot be changed
Priority: external comparator > internal comparator
8. Java tool class - Collections
ArrayList<Integer> list = new ArrayList<>(); //Batch add Collections.addAll(list, 2, 3, 5, 1, 7, 4, 8, 6); //Sorting --- using built-in comparator Collections.sort(list);//Ascending order //You can also use list Sort //Sorting - using an external comparator Collections.sort(list, new Comparator<Integer>() { @Override public int compare(Integer o1, Integer o2) { return Integer.compare(o1 ,o2 ); } }); //replace // Collections.fill(list,888);// Replace all with 888 System.out.println(list);
9 attention
- The difference between Collection and Map
Collection certificate of deposit is a value, which can be obtained by iterator for traversal
The Map stores two key values, which can't get iterators and can't be traversed (the Map can be traversed indirectly)
- Understand why Set is out of order
Disorder: the order of deposit and withdrawal is inconsistent, and disorder is not equal to random
- The difference between ArrayList and LinkedList
Differences in use:
LinkedList added
Queue mode - first in first out (removeFirst())
Stack mode - first in last out (removeLast())
Efficiency difference: because the underlying data structure of ArrayList is a one-dimensional array, the underlying data structure of LinkedList is a two-way linked list
Add - case without capacity expansion: ArrayList fast
Add capacity expansion: LinkedList fast
Delete: LinkedList quick
Modify: ArrayList fast
Query: ArrayList fast
Note: ArrayList is often used in work, because many requirements need to use the query function, and ArrayList query is faster
- Application scenarios of various collections
ArrayList: save data, thread unsafe
LinkedLinked:
Vector: deprecated, thread safe
Stack: deprecated, thread safe
HashSet: de duplication + disorder, thread unsafe
LinkedHashSet: de duplication + order, thread unsafe
TreeSet: sorting, thread unsafe
HashMap: save key+value, key de duplication, out of order, thread unsafe
LinkedHashMap: save key+value, key de duplication, orderly, thread unsafe
Hashtable: discard, save key+value, key de duplication, out of order, thread safe, piecewise locking - low efficiency
ConcurrentHashMap: save key+value, key de duplication, disorder, thread safety, local locking, CAS - high efficiency
TreeMap: save key+value and sort by Key
Properties: configuration file
- The difference between ArrayList and LinkedList
Differences in use:
LinkedList added
Queue mode - first in first out (removeFirst())
Stack mode - first in last out (removeLast())
Efficiency difference: because the underlying data structure of ArrayList is a one-dimensional array, the underlying data structure of LinkedList is a two-way linked list
Add - case without capacity expansion: ArrayList fast
Add capacity expansion: LinkedList fast
Delete: LinkedList quick
Modify: ArrayList fast
Query: ArrayList fast
Note: ArrayList is often used in work, because many requirements need to use the query function, and ArrayList query is faster
- Application scenarios of various collections
ArrayList: save data, thread unsafe
LinkedLinked:
Vector: deprecated, thread safe
Stack: deprecated, thread safe
HashSet: de duplication + disorder, thread unsafe
LinkedHashSet: de duplication + order, thread unsafe
TreeSet: sorting, thread unsafe
HashMap: save key+value, key de duplication, out of order, thread unsafe
LinkedHashMap: save key+value, key de duplication, orderly, thread unsafe
Hashtable: discard, save key+value, key de duplication, out of order, thread safe, piecewise locking - low efficiency
ConcurrentHashMap: save key+value, key de duplication, disorder, thread safety, local locking, CAS - high efficiency
TreeMap: save key+value and sort by Key
Properties: configuration file
- . . .