I’m trying to extend the AbstractSequentialList class in Java. The class implements an interface that requires the creation of a ListIterator method. I’ve created the method below to simply get started but I am getting warning messages saying:
ListIterator is a raw type. References to generic type ListIterator<E> should be parameterized.
What does this mean? I’m at a bit of a loss as to why this is giving me an erro as I run this code..
public ListIterator listIterator(int i){
ListIterator listiterator = this.listIterator();
return listiterator;
}
AbstractSequentialListis generic, and so should be the ListIterator it returns. This will ensure the type safety of operations done using that iterator. Make sure your subclass is generic (MyAbstractSequentialList<T>), and change your code to:You can take a look at Java’s
LinkedList‘s source code, it extendsAbstractSequentialList.You can also make your class non-generic, but then you’ll have to extend a concrete type of
AbstractSequentialList(i.e. with a specified type argument). On that case, replace theEs in the code above with that type as well.