I have a class Foothat extends AbstractListand implements List. This class implements some of the methods List, but some just throw UnsupportedOperationException.
toArrayis one of the last, and although the compiler does not complain about other methods that are not really implemented, it complains about the error toArray:
Class must either be declared abstract or implement abstract method toArray(T[]) in List.
public class Foo extends AbstractList implementst List {
...
public <T> T[] toArray(T[] a) throws UnsupportedOperationException {
throw new UnsupportedOperationException(error);
}
}
What is wrong here and why does the compiler still think that the method is toArray(T[])not implemented?
source
share