The introduction of a set of mathematical concepts is a model that is built up by placing individual data together. These data types can be different. The definition in software, A pile of data is stored in a single space, and the entire bucket is called a collection. This article describes the List interface and Set interface under the collection interface, as well as the Iterator. Body Collection Interface1.Collection hierarchy.JDK does not provide anyDirectImplementation: it provides more specific sub-interfaces (suchSetAndList.2. Main sub-interfaces and implementation classes of collection:
3. Common APIs of Collection:
List InterfaceList interface implementation class:ArrayList and list1.arraylist1) Features <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Examples/examples/ErMjPtcS/1bzkzqoxMC4KNKOpo6nUrcDto7qx5LOktcTK/examples + examples/examples = "http://www.2cto.com/uploadfile/Collfiles/20140405/20140405091013250.jpg" alt = "\"> 2. History List Features of consumer list1. Underlying usage ListThe implementation of the interface link list. Easy to delete and insert. 2. The default length is 0.3.20.list, which is non-thread-safe. 4. You cannot use the ArrayList method to delete or add elements during the collection traversal process. The list is modified in any way at any time unless the list is modified by the remove or add method of the iterator itself. The iterator will throw the ConcurrentModificationException iterator. Features of the iterator1. The Iterator interface is an algorithm used to quickly traverse a set. 2. The set can call the iterator method to obtain the iterator. 3. The iterator is a linear table with a cursor, used to record the addresses of the combined elements. 4. Relationship sketch between iterator and set:
1) related code piece 2) Corresponding sketch
5. Common APIs of Iterator:
Supplement: List Implementation class VectorVector, Vector
Class can implement a scalable array of objects. Features of Vector1. sequence table for ease of searching 2. Each expansion doubles the original length. 3. The default size is 104. Vector is thread-safe. The Set interface is similar to a mathematical Set. It has no sequence and cannot be repeated. It is different from the List interface. It can only have one null value. Here we will talk about his implementation classes: HashSet and TreeSet. HashSet Based on hash table MapInterface implementation. Features1. The Set using the hash algorithm is equivalent to Key2. the default value of hashMap is 16 and the loading factor is 75%. 3. HashSet is NOT thread-safe. 4. Internal principle: HashMap's key.5. this implementation is not synchronous. 6. You cannot use the ArrayList method to delete or add elements during the collection traversal process. The list is modified in any way at any time unless the list is modified by the remove or add method of the iterator itself. The iterator will throw ConcurrentModificationException Common APIs: TreeSet Features:1. The default space is 02. The binary tree algorithm is used for implementation. 3. The key4principle is TreeMap. During the traversal of the set, you cannot use the ArrayList method to delete or add elements. The list is modified at any time in any way unless the list is modified by the remove or add method of the iterator itself, concurrentModificationException5. Summary of elements stored by natural sorting