java 集合
Last updated
Last updated
// Collection 扩展了 Iterable 接口
public interface Collection<E> extends Iterable<E>{
boolean add(E element);
Iterator<E> iterator();
. . .
boolean isEmpty();
boolean contails(Object obj);
boolean contailsAll(Collection<?> c);
. . .
}
// Iterable 接口
public interface Iterable<T> {
Iterator<T> iterator();
. . .
}
// 迭代器
public interface Iterator<E>{
E next();
boolean hasNext();
void remove();
default void forEachRemaining(Consumer<? super E> action)
}