通过反射import java.lang.reflect.Method;
import java.util.ArrayList;
public class Hm_Test1 {
public static void main(String[] args) throws Exception{
ArrayList<Integer> a=new ArrayList<Integer>();
a.add(1);
Method m=a.getClass().getMethod("add",Object.class);
m.invoke(a,"Hello");
System.out.println(a);
}
} |