W
wdh3rd
Hello everyone,
Even though two methods both use the generic return type - E - I'm
getting an error saying that they're incompatible types. Here's the
truncated code:
public class CircularLinkedList<E> extends AbstractList<E> {
private class Node {
private E element;
public E element () {
return this.element;
}
} //end Node
private class CircularLinkedIterator<E> implements
dataStructs.Iterator<E> {
private Node current;
public Node current () {
return this.current;
}
public E get () {
return current.element(); //error is at this line
}
} //end CircularLinkedIterator
}//end CircularLinkedList
The error that I receive reads:
Error: incompatible types
found: E
required: E
I'm at a loss for understanding why the same generic types could
render an incompatible types error. Can anyone shine some Java
wisdom?? Thanks for any help anyone can offer.
Even though two methods both use the generic return type - E - I'm
getting an error saying that they're incompatible types. Here's the
truncated code:
public class CircularLinkedList<E> extends AbstractList<E> {
private class Node {
private E element;
public E element () {
return this.element;
}
} //end Node
private class CircularLinkedIterator<E> implements
dataStructs.Iterator<E> {
private Node current;
public Node current () {
return this.current;
}
public E get () {
return current.element(); //error is at this line
}
} //end CircularLinkedIterator
}//end CircularLinkedList
The error that I receive reads:
Error: incompatible types
found: E
required: E
I'm at a loss for understanding why the same generic types could
render an incompatible types error. Can anyone shine some Java
wisdom?? Thanks for any help anyone can offer.