作业帮 > 综合 > 作业

e.printStackTrace() ;

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/29 18:56:38
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() ;是为什么?
catch(Exception e){
e.printStackTrace() ;
}
当try语句中出现异常是时,会执行catch中的语句,java运行时系统会自动将catch括号中的Exception e 初始化,也就是实例化Exception类型的对象.e是此对象引用名称.然后e(引用)会自动调用Exception类中指定的方法,也就出现了e.printStackTrace() ;.
printStackTrace()方法的意思是:在命令行打印异常信息在程序中出错的位置及原因.(这是白话解释,比较容易理解)