当前位置:网站首页>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,用户名不对,密码不对,这种错误就需要我们来自定义异常类)
边栏推荐
- 有一说一,外包公司到底值不值得去?
- Linux环境redis集群搭建「建议收藏」
- Three.js入门
- A solution to the server encountered an internal error that prevented it from fulfilling this request [easy to understand]
- Go mode tidy reports an error go warning “all” matched no packages
- rj45对接头千兆(百兆以太网接口定义)
- 性能优化:记一次树的搜索接口优化思路
- ThreadLocal
- Write a database document management tool based on WPF repeating the wheel (1)
- Thymeleaf是什么?该如何使用。
猜你喜欢
高效并发:Synchornized的锁优化详解
全网一触即发,自媒体人的内容分发全能助手——融媒宝
The principle of ReentrantLock (to be continued)
NVIDIA已经开始测试AD106和AD107 GPU核心的显卡产品
How to identify fake reptiles?
Memblaze发布首款基于长存颗粒的企业级SSD,背后有何新价值?
关注!海泰方圆加入《个人信息保护自律公约》
ReentrantLock原理(未完待续)
SiC MOSFET的短路特性及保护
[Code Hoof Set Novice Village 600 Questions] Merge two numbers without passing a character array
随机推荐
Redis综述篇:与面试官彻夜长谈Redis缓存、持久化、淘汰机制、哨兵、集群底层原理!...
-xms -xmx(information value)
-xms -xmx(information value)
Shell script quick start to actual combat -02
C language parsing json string (json object is converted to string)
useragent online lookup
Count characters in UTF-8 string function
Implementation of a sequence table
ThreadLocal
广汽本田安全体验营:“危险”是最好的老师
Realization of character makeup
Structure of the actual combat battalion module eight operations
Shell 脚本 快速入门到实战 -02
TestCafeSummary
Apache EventMesh distributed event-driven multi-runtime
grep命令 笔试题
BOW/DOM (top)
财务盈利、偿债能力指标
find prime numbers up to n
Transfer Learning - Domain Adaptation