-
使用场景
-
性能分析
-
个人看法
public static void tryOutside() {
try {
for (int count = 1; count <= 5; count++) {
if (count == 3) {
//故意制造一下异常
int num = 1 / 0;
} else {
System.out.println("count:" + count + " 业务正常执行");
}
}
} catch (Exception e) {
System.out.println("try catch 在for 外面的情形, 出现了异常,for循环显然被中断");
}
}
public static void tryInside() {
for (int count = 1; count <= 5; count++) {
try {
if (count == 3) {
//故意制造一下异常
int num = 1 / 0;
} else {
System.out.println("count:" + count + " 业务正常执行");
}
} catch (Exception e) {
System.out.println("try catch 在for 里面的情形, 出现了异常,for循环显然继续执行");
}
}
}
Runtime runtime = Runtime.getRuntime();
long memory = runtime.freeMemory();
-
Exception table: 当前函数程序代码编译涉及到的异常; -
type:异常类型; -
target:表示异常的处理起始位; -
from:表示 try-catch 的开始地址; -
to:表示 try-catch 的结束地址;
往期推荐
拒绝写重复代码,试试这套开源的SpringBoot组件,效率翻倍~
成年人欲望程度排行榜TOP 10
Jackson视图神技:一个DTO干掉N个DTO,告别DTO爆炸问题
Lombok 造成的翻车事故,太坑了!
一款牛逼的IDEA插件神器:让代码命名变得轻松高效
MySQL模糊查询再也用不着like+%了!

