黑马程序员技术交流社区
标题:
面试小问题,求版主解惑
[打印本页]
作者:
进击的蜗牛
时间:
2015-7-16 11:17
标题:
面试小问题,求版主解惑
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处理
作者:
masai158
时间:
2015-7-16 11:47
主函数 不要在抛了。 主函数应该处理掉所以的异常,如果主函数选择抛异常的话,一旦出现异常,程序将终止运行!
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2