Re: inner-inner class referencing outer class's inherited method



well - i figured out a better way around the problem. thanks anyhow.

> i have a class called NonRepeatedDefaultMatrix
>
> NonRepeatedDefaultMatrix has an inner class KeySet<E>
>
> KeySet<E> inherits from HashSet<E>
>
> KeySet<E> has an inner class KeySetIterator<E>
>
> so, the inner-outer class tree looks like:
>
> NonRepeatedDefaultMatrix
> KeySet<E> inherits HashSet<E>
> KeySetIterator<E>
>
> note that these are inner classes, not static nested class
>
> now the problem:
>
> in a method in KeySetIterator i have a line where i am attempting to get a
> reference to the iterator returned by HashSet's iterator method.
>
> thus, if the line was written in a method in KeySet i would simply write:
>
> Iterator<E> theIterator = super.iterator();
>
> which works fine.
>
> the equivalent line i write in a method in KeySetIterator is:
>
> Iterator<E> theIterator = NonRepeatedDefaultMatrix.KeySet.super.iterator();
>
> the error I get during compilation:
>
> sourcepath/NonRepeatedDefaultMatrix.java:364: incompatible types
> found : java.util.Iterator<E>
> required: java.util.Iterator<E>
> this.theIterator = NonRepeatedDefaultMatrix.KeySet.super.iterator();
>
> obviously this error message is misleading as the types are most certainly
> compatible!
>
> i want the line to get the iterator returned by the HashSet's iterator()
> implementation, not the KeySet's iterator() implementation.
> this is necessary because the line in question is part of the
> KeySetIterator's constructor, which is called by KeySet.iterator() - which
> would obviously result in calling cycle.
>
> anyone out there still managing to read this far down understand my
> problem?
>
> better yet... anyone know how i should do this?
>
> thanks much!
>
> murat

.



Relevant Pages

  • inner-inner class referencing outer classs inherited method
    ... NonRepeatedDefaultMatrix has an inner class KeySet ... reference to the iterator returned by HashSet's iterator method. ... the equivalent line i write in a method in KeySetIterator is: ...
    (comp.lang.java.help)
  • Re: How Unit test an inner classs public method
    ... essential part of the functionality. ... best to test the inner class as part of a test suite that also tests the ... For example, with a collection and iterator, the latter ...
    (comp.lang.java.programmer)
  • Impasse: compiler/eclipse bug
    ... This code is part of an inner class for a custom collection class. ... parent class contains an instance member called "inner" of type Map<T, ... Iterator { ... cannot convert from foo to foo. ...
    (comp.lang.java.programmer)