public class TestTry {
static String s="";
public static void main(String args[]){
s = test1();
System.out.println("8 "+s);
}
public static String test1(){
try{
System.out.println("try.....");
return s = "a";
}
finally{
s="b";
System.out.println("17 "+s);
}
}
}
try..... 17 b 8 a
public class TestTry {
static String s="";
public static void main(String args[]){
s = test1();
System.out.println("8 "+s);
}
public static String test1(){
try{
System.out.println("try.....");
return s = "a";
}
finally{
return s="b";
}
}
}
try..... 8 b
public static int print() {
int c = 1;
try {
c++;
System.out.println("try执行中...");
return c+100; //--------1
} catch (Exception e) {
e.printStackTrace();
//return c; //--------4
} finally {
c++;
System.out.println("finally执行中...");
return c; //--------2
}
//return c; //---------3
}
run: try执行中... finally执行中... 3 成功构建 (总时间: 0 秒)
public static int print() {
int c = 1;
try {
c++;
System.out.println(c);
System.out.println("try");
return c+100; //--------1
}finally {
c++;
System.out.println(c);
System.out.println("finally");
}
}
run: try finally 102 成功构建 (总时间: 0 秒)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有