当前位置:网站首页>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,用户名不对,密码不对,这种错误就需要我们来自定义异常类)
边栏推荐
- 1161. Maximum Sum of Elements in Layer: Hierarchical Traversal Application Problems
- Go1.18 upgrade function - Fuzz test from scratch in Go language
- Book of the Month (202207): The Definitive Guide to Swift Programming
- 基于STM32 环形队列来实现串口接收数据
- GAC Honda Safety Experience Camp: "Danger" is the best teacher
- Transfer Learning - Domain Adaptation
- Poker Game in C# -- Introduction and Code Implementation of Blackjack Rules
- Chapter VII
- BM5 merge k sorted linked lists
- [Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
猜你喜欢

iNeuOS industrial Internet operating system, equipment operation and maintenance business and "low-code" form development tools

Teach you how to deploy Nestjs projects

高效并发:Synchornized的锁优化详解

21. Support Vector Machine - Introduction to Kernel Functions

SiC MOSFET的短路特性及保护

How programmers learn open source projects, this article tells you

Implementation of a sequence table

【PIMF】OpenHarmony 啃论文俱乐部—盘点开源鸿蒙三方库【3】

Realization of character makeup

How to debug TestCafe
随机推荐
leetcode 665. Non-decreasing Array 非递减数列(中等)
统计UTF-8字符串中的字符函数
【AcWing】The 62nd Weekly Match 【2022.07.30】
【AcWing】The 62nd Weekly Match 【2022.07.30】
sqlite3 simple operation
Verilog implements a divide-by-9 with a duty cycle of 5/18
[NLP] What is the memory of the model!
The old music player WinAmp released version 5.9 RC1: migrated to VS 2019, completely rebuilt, compatible with Win11
A shortcut to search for specific character content in idea
架构实战营模块八作业
Book of the Month (202207): The Definitive Guide to Swift Programming
架构实战营模块 8 作业
Talking about the algorithm security of network security
Shell 脚本 快速入门到实战 -02
ECCV 2022 Huake & ETH propose OSFormer, the first one-stage Transformer framework for camouflaging instance segmentation!The code is open source!...
Go1.18 upgrade function - Fuzz test from scratch in Go language
multithreaded lock
MATLAB program design and application 2.4 Common internal functions of MATLAB
grep命令 笔试题
Introduction to Audio Types and Encoding Formats in Unity