Collection interface
Public methods:
1. Add () AddAll ()
2. Delete Clear () remove () RemoveAll () Retainall () (take intersection)
3. Judge contains () Containsall () equals () Isempy ()
Two large sub-interfaces:
List interface ordered repetition
ArrayList class Bottom is the array implementation of the deletion rate slow query speed fast synchronization efficiency high
When the same elements are removed, the more complex
Vector class Bottom is also the array to achieve synchronization efficiency at the bottom and delete speed slow query fast
LinkedList class bottom is linked list implementation of the query speed slow and delete faster
Traversal method: 1. Iterator 2.toArray () 3.get () and size () 4.foreach
Set interface unordered Unique
The HashSet class data structure is a hash table that implements unordered and unique ways by depositing the hashcode () in which the object is
Method is implemented with the Equals () method.
TreeSet class unordered unique sort the underlying implementation of the data structure is that the red black tree is naturally sorted by implementing compareable ()
interface, overriding the CompareTo () method to fix the custom comparer class is to implement the Comparetor interface, overriding
Compare () method to get it done.
Common denominator: Iterator (iterator)
Iterating through the collection collection can not use the collection's own additions or deletions while using iterators, only
Use the iterator method to operate, no exception occurs
Map Interface Key-value
Method: Put ()
Remove ()
Clear ()
ContainsKey ()
Containsvalue ()
Get:
KeySet ()
Valuse ()
EntrySet ()
Get ()
HASHMAP Hash table data structure guarantees uniqueness and disorder
Case:hashmap<string,string>
Hashmap<integer,string>
Hashmap<student,string> to override the Student Hashcode () method and the Equals () method
Hashmap<string,student>
TreeMap Red and black tree data structure sorting uniqueness
Case:treemap<string,string>
Treemap<integer,string>
Treemap<student,string> Student to implement the Compareable interface, override the CompareTo method, or customize the comparison class
Treemap<string,student>
The difference between HashMap and Hashtable?
The key and value of 1.HASHMAP can be null
2.HashTable is possible, but we don't usually use it.
3.HashTable is synchronous
Collections Operation Class
1.sort
2.binarySearch find to return to the index, can not find the return (-(insertion point)-1)
3.max
4.reverse (reverse)
5.shuffle (Shuffle) Use default random source to displace a list
Java Collection Rough Summary