当前位置:网站首页>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
边栏推荐
猜你喜欢
Spark 算子之交集、并集、差集
299. Number guessing game
Day (6) of picking up matlab
[key points of final review of modern electronic assembly]
Unity shader learning
Hyperbdr cloud disaster recovery v3 Release of version 3.0 | upgrade of disaster recovery function and optimization of resource group management function
王启亨谈Web3.0与价值互联网“通证交换”
Six scenarios of cloud migration
C, calculation method and source program of bell number
一文掌握vscode远程gdb调试
随机推荐
捡起MATLAB的第(2)天
Vim使用Vundle安装代码补全插件(YouCompleteMe)
MySQL - execution process of MySQL query statement
JVM - Chapter 2 - class loader subsystem
Day (2) of picking up matlab
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
Implement default page
CVPR 2022 quality paper sharing
299. Number guessing game
[AI weekly] NVIDIA designs chips with AI; The imperfect transformer needs to overcome the theoretical defect of self attention
Meaning and usage of volatile
第十天 异常机制
leetcode-374 猜数字大小
【现代电子装联期末复习要点】
Nanny Anaconda installation tutorial
TIA botu - basic operation
OAK-D树莓派点云项目【附详细代码】
ESP32编译环境的搭建
Gartner predicts that the scale of cloud migration will increase significantly; What are the advantages of cloud migration?