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*/
は、私はそれらを修正する方法を知らないので、任意の助けをさせていただきます。あなたはListIterator
クラスで定義されたすべてのメソッドを実装するために、このエラーに
LinkedList.LinkedListIterator must implement the inherited abstract method ListIterator.previousIndex()
LinkedListIterator
ためのニーズを取得している
であるとしてそれは聞かせてあなたはそれが
ListIterator<String>
をgeneric.ie作ることができますし、また、あなたが知っているコンパイラを通知することにより、この警告を削除することができ、汎用ではありませんおそらく、初心者用のJavaの本やOracleのチュートリアルを読むことは良い投資になるでしょう。 –