当前位置:网站首页>第十天 异常机制
第十天 异常机制
2022-04-23 16:02:00 【Students Mr sun】
例子:
--异常捕获级别
throw用在方法中 throwd在方法上抛出异常
package oop.exception; public class Demo1 { public static void main(String[] args) { int a=1; int b=0; //ctrl+alt+t 异常快捷键 //捕获异常 try { System.out.println(a / b); } catch (Error e) { System.out.println("Error"); //打印异常 e.printStackTrace(); } catch (Exception e) { System.out.println("Exception"); } catch (Throwable e) { System.out.println("Throwable"); } finally { System.out.println("finally"); } //test方法中的捕获异常 try { test(1,0); } catch (ArithmeticException e) { System.out.println("asdasfasfasfas"); } finally { System.out.println("finally"); } } public static void test(int a,int b) throws ArithmeticException { if (b==0) { System.out.println("asd"); throw new ArithmeticException(); } } }
自定义异常
版权声明
本文为[Students Mr sun]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_37138380/article/details/120039430
边栏推荐
- How do you think the fund is REITs? Is it safe to buy the fund through the bank
- How important is the operation and maintenance process? I heard it can save 2 million a year?
- Grbl learning (II)
- One brush 314 sword finger offer 09 Implement queue (E) with two stacks
- Accumulation of applet knowledge points
- Timing model: gated cyclic unit network (Gru)
- Go concurrency and channel
- Unity Shader学习
- C语言自编字符串处理函数——字符串分割、字符串填充等
- 捡起MATLAB的第(3)天
猜你喜欢
C, calculation method and source program of bell number
Why disable foreign key constraints
MySQL - MySQL查询语句的执行过程
运维流程有多重要,听说一年能省下200万?
Spark 算子之filter使用
[AI weekly] NVIDIA designs chips with AI; The imperfect transformer needs to overcome the theoretical defect of self attention
Implement default page
Vision of building interstellar computing network
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
安装Redis并部署Redis高可用集群
随机推荐
GRBL学习(二)
String sorting
ES常用查询、排序、聚合语句
5 minutes, turn your excel into an online database, the magic cube net table Excel database
299. 猜数字游戏
新动态:SmartMesh和MeshBox的合作新动向
C语言自编字符串处理函数——字符串分割、字符串填充等
matplotlib教程05---操作图像
Function summary of drawing object arrangement in R language
Es common query, sorting and aggregation statements
Open source project recommendation: 3D point cloud processing software paraview, based on QT and VTK
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
TIA botu - basic operation
New developments: new trends in cooperation between smartmesh and meshbox
Coalesce and repartition of spark operators
Accumulation of applet knowledge points
Simple usage of dlopen / dlsym / dlclose
homwbrew安装、常用命令以及安装路径
Compile, connect -- Notes
ESP32_Arduino