- public class Sum{
-
- public Sum(int x,int y) {
- this.x=x;
- this.y=y;
- }
- int x;
- int y;
-
- void add( ){
-
- System.out.println(x+y);
-
- }
- }
复制代码 这个我写的 是- public class GetMethodParameter {
- public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
- Sum sum = new Sum();
- System.out.println(sum.getClass().getMethod("add",int.class,int.class).invoke(sum));
-
- }
- }
复制代码 这样写错在哪里?请教
|