当前位置:网站首页>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 .
边栏推荐
猜你喜欢
C language Getting Started Guide
Cookie和Session的区别
fianl、finally、finalize三者的区别
西安电子科技大学22学年上学期《信号与系统》试题及答案
Write a program to simulate the traffic lights in real life.
Redis的两种持久化机制RDB和AOF的原理和优缺点
Change vs theme and set background picture
12 excel charts and arrays
1. C language matrix addition and subtraction method
9. Pointer (upper)
随机推荐
【九阳神功】2019复旦大学应用统计真题+解析
Caching mechanism of leveldb
Wei Pai: the product is applauded, but why is the sales volume still frustrated
Set container
FAQs and answers to the imitation Niuke technology blog project (II)
重载和重写的区别
西安电子科技大学22学年上学期《基础实验》试题及答案
Aurora system model of learning database
1.C语言初阶练习题(1)
Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
A comprehensive summary of MySQL transactions and implementation principles, and no longer have to worry about interviews
The latest tank battle 2022 - Notes on the whole development -2
View UI plus released version 1.3.1 to enhance the experience of typescript
Rich Shenzhen people and renting Shenzhen people
[the Nine Yang Manual] 2022 Fudan University Applied Statistics real problem + analysis
3. C language uses algebraic cofactor to calculate determinant
Cloud native trend in 2022
Cookie和Session的区别
5. Function recursion exercise
(原创)制作一个采用 LCD1602 显示的电子钟,在 LCD 上显示当前的时间。显示格式为“时时:分分:秒秒”。设有 4 个功能键k1~k4,功能如下:(1)k1——进入时间修改。