当前位置:网站首页>Day 10 abnormal mechanism
Day 10 abnormal mechanism
2022-04-23 16:08:00 【Students Mr sun】








Example :

-- Exception capture level



throw Used in methods throwd Throw an exception on a method 
package oop.exception;
public class Demo1 {
public static void main(String[] args) {
int a=1;
int b=0;
//ctrl+alt+t Exception shortcut
// Capture exception
try {
System.out.println(a / b);
} catch (Error e) {
System.out.println("Error");
// Printing exception e.printStackTrace();
}
catch (Exception e) {
System.out.println("Exception");
} catch (Throwable e) {
System.out.println("Throwable");
}
finally {
System.out.println("finally");
}
//test Method
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();
}
}
}
Custom exception



版权声明
本文为[Students Mr sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231602157310.html
边栏推荐
- Hypermotion cloud migration helped China Unicom. Qingyun completed the cloud project of a central enterprise and accelerated the cloud process of the group's core business system
- 贫困的无网地区怎么有钱建设网络?
- 【自娱自乐】构造笔记 week 2
- js正则判断域名或者IP的端口路径是否正确
- 451. 根据字符出现频率排序
- Tencent offer has been taken. Don't miss the 99 algorithm high-frequency interview questions. 80% of them are lost in the algorithm
- Basic greedy summary
- Partitionby of spark operator
- PS为图片添加纹理
- Homewbrew installation, common commands and installation path
猜你喜欢

Function summary of drawing object arrangement in R language

Spark 算子之sortBy使用

Six scenarios of cloud migration

第十天 异常机制

Sortby use of spark operator

Day (9) of picking up matlab

Grbl learning (I)

Countdown 1 day ~ 2022 online conference of cloud disaster tolerance products is about to begin

Install redis and deploy redis high availability cluster

Filter usage of spark operator
随机推荐
C语言自编字符串处理函数——字符串分割、字符串填充等
Leetcode-396 rotation function
C#,贝尔数(Bell Number)的计算方法与源程序
R语言中绘制ROC曲线方法二:pROC包
ES常用查询、排序、聚合语句
Day (6) of picking up matlab
最详细的背包问题!!!
JSP learning 3
ESP32_ Arduino
VIM uses vundle to install the code completion plug-in (youcompleteme)
matplotlib教程05---操作图像
一文读懂串口及各种电平信号含义
Spark 算子之distinct使用
Filter usage of spark operator
linux上启动oracle服务
安装Redis并部署Redis高可用集群
Metalife established a strategic partnership with ESTV and appointed its CEO Eric Yoon as a consultant
捡起MATLAB的第(4)天
Ice -- source code analysis
新动态:SmartMesh和MeshBox的合作新动向