System.out.println(e.getMessage());
e.printStackTrace();
System.out.println(e)
5 回答
已采纳

ziom
TA贡献948条经验 获得超1109个赞
System.out.println(e.getMessage()); // 打印具体的异常名称 e.printStackTrace(); // 打印异常的栈追踪信息(包含异常名称) System.out.println(e) // 等同于打印e.toString();

噼喱啪啦
TA贡献392条经验 获得超170个赞
你的代码中的e,应该是某个类的引用或是说 事例对象,假设这个类是E
System.out.println(e.getMessage());
代表输出 e.getMessage(),也就是输出引用e的一个函数,这样就是输出函数的地址
e.printStackTrace();
这个代表调用类E中的printStackTrace()这个函数
System.out.println(e)
这个代表打印引用e,也就是打印这个引用的地址,java中称为哈希值

慕粉3997267
TA贡献3条经验 获得超1个赞
System.out.println(e.getMessage()); // 打印具体的异常名称 e.printStackTrace(); // 打印异常的栈追踪信息(包含异常名称) System.out.println(e) // 等同于打印e.toString();
添加回答
举报
0/150
提交
取消