- /**
- * 通过反射String调用charAt方法
- * @author Administrator
- * @throws Exception
- * @since JDK 1.6
- */
- public void getMethod() throws Exception{
- String str = "abcdefg";
- Method method = String.class.getMethod("charAt", int.class);
- System.out.println(method.invoke(str, 2));
- }
复制代码 |