I am trying to understand Java Iterator
and Iterable
interfaces
I am writing this class
class MyClass implements Iterable&
You should not do Myclass implements Iterable
since iterators are single-use. With the exception of list iterators, there's no way to return them to the start.
Incidentally, you can skip the
MyClass myClass;
public MyClassInterator(MyClass m){
myclass=m;
}
and instead of referencing
myClass
reference
MyClass.this
Your inner class is not static, so MyClass.this
will reference the instance of the enclosing class that created it.