I have this static method
public static List<? extends A> myMethod(List<? extends A> a) {
// …
}
which I’m calling using
List<A> oldAList;
List<A> newAList = (List<A>) MyClass.myMethod(oldAList);
This gives a warning because of the unchecked cast to List<A>. Is there any way of avoiding the cast?
You need to define the type returned matches the argument (and extends A)
Then you can write
or