请他们的源码:
public interface Iterator
{
public abstract boolean hasNext();
public abstract Object next();
}
public interface Collection
{
public abstract Iterator iterator();
}
public interface List extends Collection
{
...
}
public class ArrayList implements List
{
public Iterator iterator() {
return new Itr();
}
private class Itr implements Iterator {
public boolean hasNext() {
return xxx;;
}
public E next() {
return xxx;
}
}
}
Collection类中这个方法public abstract Iterator iterator();和Iterator是什么样的关系?
|
|