a picture
three points of knowledge1. iterators
- Java.util.iterator+hashnext () Next () Remove ()
- Java.lang.iterable+ rewrite iterator () returns an iterator (the container needs to use enhanced for
foreach
)
2. Comparator
- Entity classes can be sorted Java.lang.comparable+compareto
- Sort comparer (decoupling, coping with multiple collations) java.util.comparator+ overriding compare () method
Container sort: list+collections.sort () method
TreeSet, TreeMap
3. Generic type <>
Generic classes, generic methods, generic interfaces, generic erase, wildcard characters? Extends super, generics nesting
Six InterfacesCollection, Set, List, Map, Iterator, comparable
Nine common classes(Add, delete, view + Traverse) 1. ArrayList:
The underlying is an array for viewing redundant modifications @**@
add(E e) 、addindex, E element) 、removeindex) 、remove(Object o) 、setindexindex)遍历:1、for+get 2、foreach 3、Iterator 4、ListIterator
2.LinkedList:
The bottom is the linked list, which is suitable for modifying the redundant view, the method of the chain head and the tail of the chain.
3.HashSet:
Elements cannot be duplicated, so require elements to override the Hashcode and Equals methods
add(E e)remove(Object o) 遍历:1、foreach 2、Iterator
4.TreeSet:
Elements can be sorted or provide a sort of business class
5.HASHMAP:
Key cannot be repeated must override Hashcode+equals method @**@
put(K key, V value)、Remove(Object key)、ContainsKey(Object key)、Containsvalue(Object value)Traversal: Gets the value:Values()、KeySet()+Get()、EntrySet()+GetValue()Get key:KeySet()、EntrySet()+GetKey()Get key and value:KeySet()+Get()、EntrySet()+GetKey()+GetValue()
6.Properties:
Resource profile relative path get file @**@
7.Hashtable:
Both key and value cannot be null thread safe, and the efficiency is relatively low
8.Stack: Stack 9.Collections: Tool class
Java Container Summary