HashMap<Integer, String> hm = new HashMap<Integer, String>();
hm.put(1,"张三");
hm.put(2,"李四");
hm.put(3,"王五");
Class clazz = Class.forName("java.util.HashMap");
Method m =clazz.getMethod("put",Integer.class,String.class); 报错,求指导
m.invoke(hm, "aaa","bbb");
System.out.println(hm);
|
|