源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

java进行error捕获和处理示例(java异常捕获)

  • 时间:2022-12-03 11:55 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:java进行error捕获和处理示例(java异常捕获)
下面给个小例子,来验证一下error的捕获。
[u]复制代码[/u] 代码如下:
public class TestCatchError extends Error{     private static final long serialVersionUID = -351488225420878020L;     public TestCatchError(){         super();     }     public TestCatchError(String msg){         super(msg);     }     public static void main(String[] args) {         try {             throw new TestCatchError("test catch error");         } catch (Throwable t) {             System.out.println("step in the catch ~");             t.printStackTrace();         }     } }
运行结果:
[u]复制代码[/u] 代码如下:
step in the catch ~ TestCatchError: test catch error at TestCatchError.main(TestCatchError.java:23)
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部