java collections读书笔记(9)collection框架总览(2)

框架算法:

1)collection接口

add()  Adds an element to the collection.
addAll()  Adds a collection of elements to the collection.
clear()  Clears all elements from the collection.
contains()  Checks if a collection contains an element.
containsAll()  Checks if a collection contains a collection of elements.
equals()  Checks for equality with another object.
hashCode()  Returns the computed hash code for the collection

isEmpty()  Checks if a collection is empty.
iterator()  Returns an object from the collection that allows all of the collection's elements to be visited.
remove()  Clears a specific element from collection.
removeAll()  Clears a collection of elements from the collection.
retainAll()  Removes all elements from the collection not in another collection.
size()  Returns the number of elements in the collection.
toArray()  Returns the elements of a collection as an array.

Iterator接口:

interator接口是collection框架用来代替老的Enumeration接口的。

提供了在collection中遍历元素的一个标准方式。

hasNext()  Checks for more elements in the iterator.
next()  Fetches the next element of the iterator.
remove() Removes an element from the iterator.

原文地址:https://www.cnblogs.com/aomi/p/3141485.html