当前位置:网站首页>Recognize anomalies (you will understand after reading this)
Recognize anomalies (you will understand after reading this)
2022-07-31 21:36:00 【Can't write code_】
系列文章目录
文章目录
一、概念
二、基本用法
2.1基本语法
2.2Exceptions are not handled in the program
2.3try…catch处理异常
一旦 try 中出现异常, 那么 try 代码块中的程序就不会继续执行, 而是交给 catch 中的代码来执行. catch 执行完毕会继续往下执行
2.4异常也是类
catchCan receive multiple exception types
Excpetion类(不推荐)
2.5错误堆栈信息
Print the location and cause of the exception
2.6finally代码块
eg:If the block of code that closes the resource is intry代码块中,If an exception occurs, it cannot be executed.如果放在catch代码块中,The code does not raise an exception and cannot close the resource code block.
不要在finallyThe code block writes the return value
2.7异常处理流程
2.8 throws和throw关键字
三、异常体系
3.1 JDK异常继承体系
3.2非受查异常
Common unchecked exceptions:空指针异常,数组越界异常,类型转换异常
3.3受查异常
显示处理
四、自定义异常
自定义异常:
JDK内部已经帮我们提前定义好了很多的异常类,但是在某些业务场景下,出现的错误需要我们自定义异常类(When the commissioner is logged in,用户名不对,密码不对,这种错误就需要我们来自定义异常类)
边栏推荐
- Flex layout in detail
- Basic configuration of OSPFv3
- Architect 04 - Application Service Encryption Design and Practice
- 财务盈利、偿债能力指标
- 【Yugong Series】July 2022 Go Teaching Course 023-List of Go Containers
- Thymeleaf是什么?该如何使用。
- -xms -xmx(information value)
- linux查看redis版本命令(linux查看mysql版本号)
- leetcode 665. Non-decreasing Array
- ReentrantLock原理(未完待续)
猜你喜欢
统计UTF-8字符串中的字符函数
Implementation of a sequence table
[Intensive reading of the paper] iNeRF
Count characters in UTF-8 string function
Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic
leetcode: 6135. The longest ring in the graph [inward base ring tree + longest ring board + timestamp]
How to identify fake reptiles?
OSPFv3的基本配置
架构实战营模块八作业
Bika LIMS open source LIMS set - use of SENAITE (detection process)
随机推荐
Realize serial port receiving data based on STM32 ring queue
利用反射实现一个管理对象信息的简单框架
A few permanent free network transmission, convenient and simple (Intranet through tutorials)
请问我的这段sql中sql语法哪里出了错
How to debug TestCafe
[NLP] What is the memory of the model!
Three.js入门
BM3 flips the nodes in the linked list in groups of k
关注!海泰方圆加入《个人信息保护自律公约》
Verilog implements a divide-by-9 with a duty cycle of 5/18
高效并发:Synchornized的锁优化详解
Book of the Month (202207): The Definitive Guide to Swift Programming
第六章
Qualcomm cDSP simple programming example (to query Qualcomm cDSP usage, signature), RK3588 npu usage query
Several methods for deleting specified elements in Golang slices
Count characters in UTF-8 string function
How programmers learn open source projects, this article tells you
【愚公系列】2022年07月 Go教学课程 025-递归函数
【AcWing】第 62 场周赛 【2022.07.30】
第七章