I am a new-comer in Java and in process of learning. I need a an answer of following question supported with valid theory. Consider the following line-
Iterat
The implementation is defined in AbstractList
itself. Find it at its source code.
public abstract class AbstractList extends AbstractCollection implements List {
private class Itr implements Iterator {
...
}
public Iterator iterator() {
return new Itr();
}
}
Try
System.out.println(new ArrayList().iterator().getClass().getName());
output
java.util.AbstractList$Itr