I have the following code
public class A extends Iterable<Integer> {
...
public Iterator<Integer> iterator() {
return new Iterator<Integer>() {
A a;
public boolean hasNext() {
...
}
public Integer next() {
...
}
public void remove(){
...
}
};
I would like to initialize the "a" field in the anonymous class with the instance of A that iterator method was called on. Is it possible?
Thank you.