----------------------android培训、java培训、期待与您交流! ----------------------
/*
* 功能:ArrayList<Integer> list = new ArrayList<Integer>();
* 在这个泛型为Integer的ArrayList中存放一个String类型的对象。
* */
import java.lang.reflect.Method;
import java.util.ArrayList;
public class ArrayListDemo {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
ArrayList list = new ArrayList();
String name = "add";
Class parameterType = Object.class;
Method method = ArrayList.class.getMethod(name, parameterType);
method.invoke(list, "Good");
System.out.println(list.get(0));
}
}
----------------------android培训、java培训、期待与您交流! ----------------------
420

被折叠的 条评论
为什么被折叠?



