当前位置:网站首页>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,用户名不对,密码不对,这种错误就需要我们来自定义异常类)
边栏推荐
- grep command written test questions
- Teach you how to deploy Nestjs projects
- 每月一书(202207):《Swift编程权威指南》
- 【PIMF】OpenHarmony 啃论文俱乐部—盘点开源鸿蒙三方库【3】
- [PIMF] OpenHarmony Thesis Club - Inventory of the open source Hongmeng tripartite library [3]
- Daily practice——Randomly generate an integer between 1-100 and see how many times you can guess.Requirements: The number of guesses cannot exceed 7 times, and after each guess, it will prompt "bigger"
- Implementing a Simple Framework for Managing Object Information Using Reflection
- Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic
- Talking about the algorithm security of network security
- 【核心概念】图像分类和目标检测中的正负样本划分以及架构理解
猜你喜欢

Efficient Concurrency: A Detailed Explanation of Synchornized's Lock Optimization

SiC MOSFET的短路特性及保护

Arduino框架下STM32全系列开发固件安装指南

Flex layout in detail

focus on!Haitai Fangyuan joins the "Personal Information Protection Self-discipline Convention"

如何才能真正的提高自己,成为一名出色的架构师?

Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic

Structure of the actual combat battalion module eight operations

Three.js入门

Write a database document management tool based on WPF repeating the wheel (1)
随机推荐
grep command written test questions
SiC MOSFET的短路特性及保护
focus on!Haitai Fangyuan joins the "Personal Information Protection Self-discipline Convention"
移动web开发02
【论文精读】iNeRF
matplotlib ax bar color 设置ax bar的颜色、 透明度、label legend
Embedded development has no passion, is it normal?
ojdbc8 "Recommended Collection"BM3 将链表中的节点每k个一组翻转
【AcWing】第 62 场周赛 【2022.07.30】
rj45 to the connector Gigabit (Fast Ethernet interface definition)
idea中搜索具体的字符内容的快捷方式
性能优化:记一次树的搜索接口优化思路
Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic
Redis综述篇:与面试官彻夜长谈Redis缓存、持久化、淘汰机制、哨兵、集群底层原理!...
利用反射实现一个管理对象信息的简单框架
Returns a zero-length array or empty collection, do not return null
Structure of the actual combat battalion module eight operations
UserAgent resolution
One thing to say, is outsourcing company worth it?