当前位置:网站首页>第十天 异常机制
第十天 异常机制
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
边栏推荐
- 【第5节 if和for】
- 多线程原理和常用方法以及Thread和Runnable的区别
- Day (5) of picking up matlab
- 撿起MATLAB的第(9)天
- 运维流程有多重要,听说一年能省下200万?
- Sortby use of spark operator
- 王启亨谈Web3.0与价值互联网“通证交换”
- JS regular détermine si le nom de domaine ou le chemin de port IP est correct
- [split of recursive number] n points K, split of limited range
- Intersection, union and difference sets of spark operators
猜你喜欢
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
Day (9) of picking up matlab
New developments: new trends in cooperation between smartmesh and meshbox
建设星际计算网络的愿景
Cap theorem
Spark 算子之distinct使用
matplotlib教程05---操作图像
Install redis and deploy redis high availability cluster
Config learning notes component
捡起MATLAB的第(7)天
随机推荐
【现代电子装联期末复习要点】
Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years
糖尿病眼底病变综述概要记录
How do you think the fund is REITs? Is it safe to buy the fund through the bank
utils. Deprecated in35 may be cancelled due to upgrade. What should I do
GRBL学习(一)
一文掌握vscode远程gdb调试
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
Intersection, union and difference sets of spark operators
如何进行应用安全测试(AST)
Partitionby of spark operator
捡起MATLAB的第(9)天
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
TIA博图——基本操作
Coalesce and repartition of spark operators
Load Balancer
Spark 算子之交集、并集、差集
Day (4) of picking up matlab
js正则判断域名或者IP的端口路径是否正确
ESP32_Arduino