当前位置:网站首页>Difference and understanding between detected and non detected anomalies
Difference and understanding between detected and non detected anomalies
2022-07-06 13:39:00 【Wake up duck, did you program today?】
1、 B. abnormal
The so-called checked exception actually indicates that it is at the time of compilation , Exceptions to force check , This exception needs to be displayed through try/catch To capture or through throws Throw it out, otherwise the program cannot be compiled .
2、 Undetected abnormal
The so-called unchecked exception means that the compiler does not need to force to check the exception , This exception does not need to be displayed to catch or throw .
stay java All exceptions inside need to be inherited java.lang.Throwable This class is shown below :

Throwable There are two direct subclasses :
- Error: It refers to errors at the bottom of the program or at the hardware level , Like the usual OOM abnormal ( Memory overflow exception ) So this exception has nothing to do with the program itself, so it doesn't need to check whether it belongs to Undetected abnormal .
- Exception: It indicates some exceptions in the program , It may be caused by lax procedures, such as NullPointerException( Null pointer exception ) etc. ,Exception Two exception types are derived
- RuntimeException: The runtime exception belongs to the non inspected exception
- other Exception
Summary :
So in addition to Error and RuntimeException as well as RuntimeException Outside the derived class of , Other exceptions belong to the detected exceptions, such as :IOException and SQLException, In fact, the reason is Java I think the main reason for designing some exceptions for mandatory inspection is :
Consider the correctness of the program 、 stability 、 reliability , As mentioned above, database exceptions are unexpected exceptions of the program, but once there is a problem, it will cause an occupation of resources and cause some problems in the program , So we need to catch these problems. Once there is a problem, we can deal with it in time , If we operate the database try/catch And then finally close xxx.close Close the connection , So generally speaking, the detected exception is an exception that cannot be judged in the program. Let's use try/catch Capture .
边栏推荐
- 【九阳神功】2019复旦大学应用统计真题+解析
- View UI plus releases version 1.1.0, supports SSR, supports nuxt, and adds TS declaration files
- 杂谈0516
- 优先队列PriorityQueue (大根堆/小根堆/TopK问题)
- 甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
- About the parental delegation mechanism and the process of class loading
- MySQL limit x, -1 doesn't work, -1 does not work, and an error is reported
- 12 excel charts and arrays
- Arduino+ water level sensor +led display + buzzer alarm
- There is always one of the eight computer operations that you can't learn programming
猜你喜欢
随机推荐
8. C language - bit operator and displacement operator
西安电子科技大学22学年上学期《信号与系统》试题及答案
ArrayList的自动扩容机制实现原理
JS interview questions (I)
Have you encountered ABA problems? Let's talk about the following in detail, how to avoid ABA problems
Redis实现分布式锁原理详解
9.指针(上)
Implement queue with stack
5. Download and use of MSDN
MySQL lock summary (comprehensive and concise + graphic explanation)
Pit avoidance Guide: Thirteen characteristics of garbage NFT project
这次,彻底搞清楚MySQL索引
西安电子科技大学22学年上学期《射频电路基础》试题及答案
Leetcode. 3. Longest substring without repeated characters - more than 100% solution
C language to achieve mine sweeping game (full version)
Cloud native trend in 2022
Set container
(超详细二)onenet数据可视化详解,如何用截取数据流绘图
强化学习系列(一):基本原理和概念
MySQL事务及实现原理全面总结,再也不用担心面试









