我的问题是:是否可以仅通过实施来通过容器Iterator
,即不实施Iterable
?
是否有可能做到这一点:
//From somewhere
Container c = new Container();
//I add elements to the list in the c object.
for(String s : c){
//Warning: It is not applicable for this expression...
}
class Container implements Iterator<String>{
//Here I implement a single linked list
//Here I implement all of the methods of Iterator
}