Introduction to Java collection classes (re-learn)
a . Collection (collection), map interface The two should be parallel relations.
1.MAP Introduction
The map is stored as a key value (Key-value) pair, with 2 values. Use key to find value (ex: name-phone, call by name), object created by map key is
Can not be repeated. Its two common subclasses: the HashMap class and the Hashtable class.
HashMap class: Unordered storage, key not allowed to repeat
Hashtable class: Unordered storage, key not allowed to repeat
The key value can be obtained by means of the map method keyset all key value, return is a set set, value can be used by the map method of the values method to get the value of full value. Then traverse through the iterator.
2.Collection (Collection Parent interface)
Collection subinterfaces have (common interface) A value: list, set, queue, etc. these three interfaces the list interface and the set interface are sub-interfaces of the collection
(1) List interface:
The contents of the list can be duplicated, that is, they can have the same value. Example: Adding ("a") and ("a") are the common classes of implementations that are possible: the Arrarylist class and the vector class Arrarylist class are introduced in JDK1.2, using asynchronous processing, high performance, and non-thread-safe. Vector class is introduced in JDK1.0, the use of synchronous processing, low performance, belonging to the thread-safe.
(2) Set interface:
Can not repeat the content, but can be sorted, break into the order of its two commonly used subclasses: HashSet class and TreeSet class HashSet class is hashed, not stored in order (such as the input is alphabetical, but the output is random), is random, certainly can not be sorted;
TreeSet classes are stored in an orderly manner (such as in alphabetical order, although not entered alphabetically), this can be sorted.
two. Iterator interface :
The standard operation of the set output, as long as the collection is output with iterator, provides a way for the object to get the iterator in collection. Note that when you use the iterator output, you cannot remove the elements from the collection by removing the collection, otherwise an exception occurs.
Java Collection Class Simple summary (re-learn)