public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
//建立ArrayList<Integer>对象
ArrayList<Integer> list = new ArrayList<Integer>();
String str ="wo yao jin hei ma!";
//用放射调用list的方法
Method[] method =list.getClass().getMethods();
System.out.println(method[0].invoke(list, str));
System.out.println(list);
}
像这种情况,在面试的时候可以直接抛出异常吗?还是要try catch处理
|
|