package demo02;
import java.lang.reflect.Method;
import java.util.ArrayList;
public class demo04 {
//ArrayList<String> list 添加int类型数据
public static void main(String[] args) throws Exception {
//泛型擦除(字节码文件中没有泛型)
ArrayList<String> arr =new ArrayList<String>();
arr.add("abc");
Class c =arr.getClass();
Method addd =c.getMethod("add", Object.class);
addd.invoke(arr, 1);
System.out.println(arr);
for(Object obj:arr){
System.out.println(obj);
}
}
}