一段代码抛出多种异常时:
好几段
catchcatch (FileNotFoundException e) {System.out.println("d:/LOL.exe不存在");e.printStackTrace();} catch (ParseException e) {System.out.println("日期格式解析错误");e.printStackTrace();}
在一个
catch里if (e instanceof FileNotFoundException) System.out.println("d:/LOL.exe不存在"); if (e instanceof ParseException) System.out.println("日期格式解析错误");
