Using Java 1.4 I had extended ArrayList to disallow null entries being added to the list. All I had to do was override one of the constructors and the add methods to check for null entries in the collection and/or null parameters.
With ArrayList in 1.5 using generics I'd like to take advantage of this. I've changed my
extends for the class to
public class MyArrayList<E extends ArrayList<E>>
But the constructor with the collection parameter, add and addAll methods give an error.
public MyArrayList(final Collection<? extends E> c) {
super(c);
checkCollection(c);
}
public boolean add(final E obj) {
ProgUtils.checkParameterNull("obj", obj);
return super.add(obj);
}
The compiler give 'The constructor Object(Collection<capture#4-of ? extends E>) is undefined' and 'The method add(E) is undefined for the type Object'.
Can anyone point me to the appropriate tutorial/blog that explains how to extend a class that uses generics?
Thanks
Lori <*>