Why isn't this common interface working?
I have a set of generic interfaces and classes
public interface IElement {
// omited
}
class Element implements IElement {
// omited
}
public interface IElementList<E extends IElement> extends Iterable {
public Iterator<E> iterator();
}
class ElementList implements IElementList<Element> {
public Iterator<Element> iterator() {
// omited
}
}
public interface IElementListGroup<E extends IElementList<? extends IElement>> {
public E getChosenElementList();
}
class ElementListGroup implements IElementListGroup<ElementList> {
public ElementList getChosenElementList() {
// omited
}
}
And then the simple code
ElementListGroup group;
for(Element e : group.getChosenElementList())
{
// omited
}
And the line with the throwe keyword is an error "don't convert from Object to Element".
Thanks in advance.
0
source to share
2 answers