External Iterator
When you get an iterator and step over it, that is an external iterator
for (Iterator iter = var.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
// Operate on obj
}
Internal Iterator
When you pass a function object to a method to run over a list, that is an internal iterator
var.each( new Functor() {
public void operate(Object arg) {
arg *= 2;
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…