+--java.util.List [I]+--java.util.ArrayList [C]+--java.util.LinkedList [C]+--java.util.Vector [C]+--java.util.Stack [C]+--java.util.Set [I]+--java.util.HashSet [C]+--java.util.SortedSet [I]+--java.util.TreeSet [C]
+--java.util.SortedMap [I]+--java.util.TreeMap [C]+--java.util.Hashtable [C]+--java.util.HashMap [C]+--java.util.LinkedHashMap [C]+--java.util.WeakHashMap [C]
Iterator it = collection.iterator(); // 获得一个迭代子 while(it.hasNext()) { Object obj = it.next(); // 得到下一个元素 }
Hashtable numbers = new Hashtable(); numbers.put("one", new Integer(1)); numbers.put("two", new Integer(2)); numbers.put("three", new Integer(3)); 要取出一个数,比如2,用相应的key: Integer n = (Integer)numbers.get("two"); System.out.println("two =" + n);
使用keySet()抽取key序列,将map中的所有keys生成一个Set。使用values()抽取value序列,将map中的所有values生成一个Collection。
(3)常用方法HashMap():构造一个空的HashMap实例HashMap(int capacity):构造一个带容量大小的HashMap实例HashMap(int capacity, float loadFactor):构造一个带容量和load factor的HashMap实例HashMap(Map<? extends K, ? extends V> map):构造一个从另一个Map复制过来的HashMap实例
void clear():删除Hash Map集合中的所有元素(映射)boolean containsKey(Object key):判定Hash Map集合中是否包含指定的keyboolean containsValue(Object value):判定Hash Map集合中是否包含只指定的valueSet<Entry<K, V>> entrySet():将Hash Map集合中的所有映射返回到一个set集合中V get(Object key):获得Hash Map集合中指定key对象的valueboolean isEmpty():判定Hash Map集合是否为空Set<K> keySet():返回Hash Map集合中一组keys对象V put(K key, V value):往Hash Map集合中添加一对键值对(元素)void putAll(Map<? extends K, ? extends V> map):将一个Hash Map中的所有映射复制到另外一个map中V remove(Object key):删除指定的key对象int size():获得Hash Map集合中元素的个数C ollection<V> values():返回hash map集合中所有的values到一个Collection集合
abstract boolean
|
add(E object)
Adds the specified object at the end of this
List . |
abstract void
|
add(int location, E object)
Inserts the specified object into this
List at the specified location. |
abstract boolean
|
addAll(Collection<? extends E>
collection)
Adds the objects in the specified collection to the end of this
List . |
abstract boolean
|
addAll(int location, Collection<? extends E>
collection)
Inserts the objects in the specified collection at the specified location in this
List . |
abstract void
|
clear()
Removes all elements from this
List , leaving it empty. |
abstract boolean
|
Tests whether this
List contains the specified object. |
abstract boolean
|
Compares the given object with the
List , and returns true if they represent the same object
using a class specific comparison. |
abstract E
|
get(int location)
Returns the element at the specified location in this
List . |
abstract int
|
hashCode()
Returns the hash code for this
List . |
abstract int
|
Searches this
List for the specified object and returns the index of the first occurrence. |
abstract boolean
|
isEmpty()
Returns whether this
List contains no elements. |
abstract Iterator<E>
|
iterator()
Returns an iterator on the elements of this
List . |
abstract E
|
remove(int location)
Removes the object at the specified location from this
List . |
abstract boolean
|
Removes the first occurrence of the specified object from this
List . |
abstract boolean
|
removeAll(Collection<?>
collection)
Removes all occurrences in this
List of each object in the specified collection. |
abstract E
|
set(int location, E object)
Replaces the element at the specified location in this
List with the specified object. |
abstract int
|
size()
Returns the number of elements in this
List . |
abstract Object[]
|
toArray()
Returns an array containing all elements contained in this
List . |
boolean
|
add(E object)
Adds the specified object at the end of this
ArrayList . |
void
|
add(int index, E object)
Inserts the specified object into this
ArrayList at the specified location. |
boolean
|
addAll(Collection<? extends E>
collection)
Adds the objects in the specified collection to this
ArrayList . |
boolean
|
addAll(int
index, Collection<? extends E> collection)
Inserts the objects in the specified collection at the specified location in this List.
|
void
|
clear()
Removes all elements from this
ArrayList , leaving it empty. |
boolean
|
Searches this
ArrayList for the specified object. |
boolean
|
Compares the specified object to this list and return true if they are equal.
|
E
|
get(int index)
Returns the element at the specified location in this list.
|
int
|
hashCode()
Returns the hash code of this list.
|
boolean
|
isEmpty()
Returns if this
Collection contains no elements. |
Iterator<E>
|
iterator()
Returns an iterator on the elements of this list.
|
E
|
remove(int index)
Removes the object at the specified location from this list.
|
boolean
|
Removes one instance of the specified object from this
Collection if one is contained (optional). |
E
|
set(int index, E object)
Replaces the element at the specified location in this
ArrayList with the specified object. |
int
|
size()
Returns the number of elements in this
ArrayList . |
toArray()
Returns a new array containing all elements contained in this
ArrayList . |
boolean
|
add(E object)
Adds the specified object at the end of this
LinkedList . |
boolean
|
addAll(Collection<? extends E>
collection)
Adds the objects in the specified Collection to this
LinkedList . |
void
|
addFirst(E object)
Adds the specified object at the beginning of this
LinkedList . |
void
|
addLast(E object)
Adds the specified object at the end of this
LinkedList . |
void
|
clear()
Removes all elements from this
LinkedList , leaving it empty. |
boolean
|
Searches this
LinkedList for the specified object. |
E
|
get(int location)
Returns the element at the specified location in this list.
|
E
|
getFirst()
Returns the first element in this
LinkedList . |
E
|
getLast()
Returns the last element in this
LinkedList . |
int
|
Searches this list for the specified object and returns the index of the first occurrence.
|
E
|
peek()
Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque), or returns
null if
this deque is empty. |
E
|
poll()
Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns
null if
this deque is empty. |
E
|
pop()
Pops an element from the stack represented by this deque.
|
void
|
push(E e)
Pushes an element onto the stack represented by this deque (in other words, at the head of this deque) if it is possible to do so immediately without violating capacity restrictions, returning
true upon
success and throwing an IllegalStateException if no space is currently available. |
E
|
remove()
Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque).
|
E
|
set(int location, E object)
Replaces the element at the specified location in this
LinkedList with the specified object. |
int
|
size()
Returns the number of elements in this
LinkedList . |
toArray()
Returns a new array containing all elements contained in this
LinkedList . |
abstract boolean
|
add(E object)
Adds the specified object to this set.
|
abstract boolean
|
addAll(Collection<? extends E>
collection)
Adds the objects in the specified collection which do not exist yet in this set.
|
abstract void
|
clear()
Removes all elements from this set, leaving it empty.
|
abstract boolean
|
Searches this set for the specified object.
|
abstract boolean
|
containsAll(Collection<?>
collection)
Searches this set for all objects in the specified collection.
|
abstract boolean
|
Compares the specified object to this set, and returns true if they represent the same object using a class specific comparison.
|
abstract int
|
hashCode()
Returns the hash code for this set.
|
abstract boolean
|
isEmpty()
Returns true if this set has no elements.
|
abstract Iterator<E>
|
iterator()
Returns an iterator on the elements of this set.
|
abstract boolean
|
Removes the specified object from this set.
|
abstract boolean
|
removeAll(Collection<?>
collection)
Removes all objects in the specified collection from this set.
|
abstract boolean
|
retainAll(Collection<?>
collection)
Removes all objects from this set that are not contained in the specified collection.
|
abstract int
|
size()
Returns the number of elements in this set.
|
abstract <T> T[]
|
toArray(T[] array)
Returns an array containing all elements contained in this set.
|
abstract Object[]
|
toArray()
Returns an array containing all elements contained in this set.
|
原文地址:http://blog.csdn.net/u012637501/article/details/41447427