I recently came across something like this ...
public final class Foo<T> implements Iterable<T> { //... public void remove(T t) { /* banana banana banana */ } //... public Iterator<T> Iterator { return new Iterator<T>() { //... @Override public void remove(T t) { // here, 'this' references our anonymous class... // 'remove' references this method... // so how can we access Foo remove method? } //... }; } }
Is there a way to do what I'm trying to keep as an anonymous class? Or do we need to use an inner class or something else?
source share