我不明白为什么我在使用 listIterator 时会出错?我得到错误的地方是评论。
这是我的代码:
/**
Returns an iterator for iterating through this list.
@return an iterator for iterating through this list
*/
public ListIterator<String> listIterator()
{
return new LinkedListIterator();
// error here it says: Type safety: The expression of type
// LinkedList.LinkedListIterator needs unchecked conversion to conform
// to ListIterator<String>
}
class Node
{
public Object data;
public Node next;
}
class LinkedListIterator implements ListIterator
/* here also it says:The type LinkedList.LinkedListIterator must implement
the inherited abstract method ListIterator.previousIndex() when i implement
the listIterator it says:ListIterator is a raw type. References to generic
type ListIterator<E> should be parameterized*/
我不知道如何解决它们,因此将采取任何帮助。谢谢你