Java集合框架是用来存储对象组的,也许你会想不是已经有数组了吗,数组不是可以存储这些吗?确实,数组是可以存储对象,但是某些特定的情况,人们更倾向于使用集合框架,因为它提供了丰富的功能。下面是集合框架一个顶层接口。
public interface Collection<E> extends Iterable<E> {
int size();
boolean isEmpty();
boolean contains(Object o);
Iterator<E> iterator();
Object[] toArray();
boolean add(E e);
boolean remove(Object o);
boolean containsAll(Collection<?> c);
boolean addAll(Collection<? extends E> c);
boolean removeAll(Collection<?> c);
boolean retainAll(Collection<?> c);
void clear();
boolean equals(Object o);
int hashCode();
}