Collections => Collection is the ancestor of all list and set, the list must hold objects in a particular order, set cannot have duplicate elements
The ArrayList => uses array-made list, allowing for fast random access, compared to the linkedlist of the element placement and removal motion.
LinkedList => provides optimal sequential access, suitable for placement and removal of elements, and random access actions are slower than ArrayList
HashSet => is a kind of collection, but only holds the unique value, is the search time to see the very important set, the hash method is the actual set, so access time
complexity = O (1)
TreeSet => ditto, but the elements that are deposited are arranged so that the speed is slower than the HashSet
Linkedhashset =>
Performance is likely to was just slightly below that of HashSet, due to the added expense of maintaining the
Linked list, with one exception:iteration over a linkedhashset requires time proportional to the size of the
Set, regardless of its capacity. Iteration over a hashset are likely to being more expensive, requiring time
proportional to its capacity.
Bitset => can efficiently save a large amount of
========================
HashMap => used to replace Hashtable, save (key/value) pairs
TreeMap => Storage (key/value) pairs, which is automatically sorted by key value
Linkedhashmap =>
Performance is likely to was just slightly below that of HashMap, due to the added expense of maintaining the
Linked list, with one exception:iteration on the collection-views of a linkedhashmap requires time
Proportional to the size of the map, regardless of it capacity. Iteration over a HashMap are likely to being more
Expensive, requiring time proportional to its capacity.
Identityhashmap =>
This is has better locality for large tables than does using separate.) For many JRE implementations and
Operation mixes, this class would yield better performance than HASHMAP (which uses chaining rather than
Linear-probing
Weakhashmap => in this map, because each value has only one physical and thus saves the space, once the program needs a value, it searches in the map
Existing objects and using the found object (rather than recreating one), since this is a time-saving technique, so it is convenient to allow the GC to automatically clean
The key and value, once the key is not in use, will trigger the cleanup
--------------------------------------------------------------------------------
Container Introduction
1. Classification of containers
1.1. Collection: A set of independent elements that hold only one element in each location.
1 List: Elements are placed in the order of element placement, will not be rearranged.
2 Set: Do not pick up the duplicate element of love, it will use its own internal arrangement mechanism
1.2. MAP: A group of pairs of Key-value objects, that are held key-value pairs.
There is no duplicate key in the map, it has its own internal arrangement mechanism.
2. The element types in the container are object. When you get an element from a container, you must convert it to its original type.
It's easier to understand if you look at the following one.
Write a piece of code that iterates through the elements of a list
List, MAP, set three interfaces, when accessing elements, each have what characteristics.
Import java.util.*;
public class Test
{
public static void Main (String [] arge)
{
List List = new ArrayList ();
List.add (0, "a");
List.add (1, "B");
List.add (2, "C");
List.add (3, "D");
while (Iterator it = List.iterator (); It.hasnext ())
{
Object element = It.next ();
SYSTEM.OUT.PRINTLN (Element);
}
}
}
List, Map, Set
List is accessed and valued by subscript.
Map key value correspondence to access
The set access element is unordered