当前位置:网站首页>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 .
边栏推荐
- Questions and answers of "Fundamentals of RF circuits" in the first semester of the 22nd academic year of Xi'an University of Electronic Science and technology
- A piece of music composed by buzzer (Chengdu)
- 5.函数递归练习
- C language Getting Started Guide
- Redis的两种持久化机制RDB和AOF的原理和优缺点
- string
- 杂谈0516
- PriorityQueue (large root heap / small root heap /topk problem)
- [面试时]——我如何讲清楚TCP实现可靠传输的机制
- 1.初识C语言(1)
猜你喜欢
MySQL事务及实现原理全面总结,再也不用担心面试
西安电子科技大学22学年上学期《基础实验》试题及答案
arduino+DS18B20温度传感器(蜂鸣器报警)+LCD1602显示(IIC驱动)
MPLS experiment
优先队列PriorityQueue (大根堆/小根堆/TopK问题)
3. C language uses algebraic cofactor to calculate determinant
仿牛客技术博客项目常见问题及解答(三)
[hand tearing code] single case mode and producer / consumer mode
Application architecture of large live broadcast platform
[during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
随机推荐
5. Function recursion exercise
[the Nine Yang Manual] 2019 Fudan University Applied Statistics real problem + analysis
[中国近代史] 第九章测验
【九阳神功】2019复旦大学应用统计真题+解析
[中国近代史] 第六章测验
C language Getting Started Guide
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
CorelDRAW plug-in -- GMS plug-in development -- Introduction to VBA -- GMS plug-in installation -- Security -- macro Manager -- CDR plug-in (I)
仿牛客技术博客项目常见问题及解答(一)
Redis cache obsolescence strategy
View UI plus released version 1.3.1 to enhance the experience of typescript
View UI plus released version 1.3.0, adding space and $imagepreview components
[中国近代史] 第五章测验
MySQL中count(*)的实现方式
Cookie和Session的区别
2. C language matrix multiplication
The latest tank battle 2022 - Notes on the whole development -2
The latest tank battle 2022 - full development notes-3
MySQL事务及实现原理全面总结,再也不用担心面试
8.C语言——位操作符与位移操作符