java进行error捕获和处理示例(java异常捕获)
下面给个小例子,来验证一下error的捕获。
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();
}
}
}
运行结果:
step in the catch ~
TestCatchError: test catch error
at TestCatchError.main(TestCatchError.java:23)
相关文章
java面试常见问题---ConcurrentHashMap
ConcurrentHashMap是由Segment数组结构和HashEntry数组结构组成。Segment的结构和HashMap类似,是一种数组和链表结构,今天给大家普及java面试常见问题---ConcurrentHashMap知识,一起看看吧2021-06-06
SpringCloud基于SpringAMQP实现消息队列及原理解析
Spring AMQP作为Spring框架的一部分,是一套用于支持高级消息队列协议(AMQP)的工具,这篇文章主要介绍了SpringCloud基于SpringAMQP实现消息队列及原理解析,需要的朋友可以参考下2024-04-04


最新评论