Imagine I extended the List interface to add a method as follows:
public interface MyList<E> extends List<E> {
<R super E> MyList<R> castTo(Class<R> klass);
}
Why is this illegal? Am I just doing it in the wrong way because you should definitely be able to do this.
for example I would like to do something like the following:
MyList<? extends X> someList = // list from somewhere
MyList<X> xs = someList.castTo(X.class)