当前位置:网站首页>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
边栏推荐
- Questions about disaster recovery? Click here
- Method 2 of drawing ROC curve in R language: proc package
- 【现代电子装联期末复习要点】
- linux上啟動oracle服務
- MySQL - execution process of MySQL query statement
- Application case of GPS Beidou high precision satellite time synchronization system
- The principle and common methods of multithreading and the difference between thread and runnable
- Spark 算子之交集、并集、差集
- Day (8) of picking up matlab
- Basic greedy summary
猜你喜欢

捡起MATLAB的第(7)天

How to upgrade openstack across versions

GRBL学习(一)

MySQL - execution process of MySQL query statement
![Merging of Shanzhai version [i]](/img/e7/f301697aea879bcad8cef70ca890cc.png)
Merging of Shanzhai version [i]

Questions about disaster recovery? Click here

TIA botu - basic operation

运维流程有多重要,听说一年能省下200万?

Construction of esp32 compilation environment

JVM - Chapter 2 - class loader subsystem
随机推荐
Day (2) of picking up matlab
Coalesce and repartition of spark operators
Day (4) of picking up matlab
Function summary of drawing object arrangement in R language
捡起MATLAB的第(6)天
Merging of Shanzhai version [i]
utils. Deprecated in35 may be cancelled due to upgrade. What should I do
Homewbrew installation, common commands and installation path
Matplotlib tutorial 05 --- operating images
[self entertainment] construction notes week 2
Government cloud migration practice: Beiming digital division used hypermotion cloud migration products to implement the cloud migration project for a government unit, and completed the migration of n
Questions about disaster recovery? Click here
ESP32_Arduino
Download and install mongodb
leetcode-374 猜数字大小
GRBL学习(一)
js正則判斷域名或者IP的端口路徑是否正確
The system research problem that has plagued for many years has automatic collection tools, which are open source and free
实现缺省页面
一文掌握vscode远程gdb调试