e.printStackTrace() ; try{ BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String inputLine=input.readline(); int i=Integer.parseInt(inputLine).intValue(); } catch(Exception e){ e.printStackTrace() ; }在后面加e.printSta
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/20 05:58:56
![e.printStackTrace() ; try{ BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String inputLine=input.readline(); int i=Integer.parseInt(inputLine).intValue(); } catch(Exception e){ e.printStackTrace() ; }在后面加e.printSta](/uploads/image/z/14368093-61-3.jpg?t=e.printStackTrace%28%29+%3B+try%7B+BufferedReader+input%3Dnew+BufferedReader%28new+InputStreamReader%28System.in%29%29%3B+String+inputLine%3Dinput.readline%28%29%3B+int+i%3DInteger.parseInt%28inputLine%29.intValue%28%29%3B+%7D+catch%28Exception+e%29%7B+e.printStackTrace%28%29+%3B+%7D%E5%9C%A8%E5%90%8E%E9%9D%A2%E5%8A%A0e.printSta)
e.printStackTrace() ; try{ BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String inputLine=input.readline(); int i=Integer.parseInt(inputLine).intValue(); } catch(Exception e){ e.printStackTrace() ; }在后面加e.printSta
e.printStackTrace() ;
try{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
String inputLine=input.readline();
int i=Integer.parseInt(inputLine).intValue();
}
catch(Exception e){
e.printStackTrace() ;
}
在后面加e.printStackTrace() ;是为什么?
e.printStackTrace() ; try{ BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String inputLine=input.readline(); int i=Integer.parseInt(inputLine).intValue(); } catch(Exception e){ e.printStackTrace() ; }在后面加e.printSta
catch(Exception e){
e.printStackTrace() ;
}
当try语句中出现异常是时,会执行catch中的语句,java运行时系统会自动将catch括号中的Exception e 初始化,也就是实例化Exception类型的对象.e是此对象引用名称.然后e(引用)会自动调用Exception类中指定的方法,也就出现了e.printStackTrace() ;.
printStackTrace()方法的意思是:在命令行打印异常信息在程序中出错的位置及原因.(这是白话解释,比较容易理解)