For example, lets say you have two classes:
public class TestA {} public class TestB extends TestA{}
I have a method that returns a L
L
This is possible due to type erasure. You will find that
List x = new ArrayList(); List y = new ArrayList(); x.getClass().equals(y.getClass()); // true
Internally both lists are of type List. For that reason you can't cast one to the other - there is nothing to cast.
List