public class Define{
public static void main(String[] args) {
Tool<Person> tool=new Tool<Person>();
Student stu=(Student)(tool.addElement(new Person("ad",13,'男'))).get(0);
}
}
public class Tool<T>{
public <A> LinkedList addElement(T a){
LinkedList<T> ll=new LinkedList<T>();
ll.add(a);
return ll;
}
}
Student继承Person,编译已经通过了,运行时抛出java.lang.ClassCastException: bean.Person cannot be cast to bean.Student,请问什么原因?