public class TryExer {
public static void main(String[] args) {
String test = test();
System.out.printf("返回:"+test);
}
public static String test(){
try {
System.out.println("try");
return "try";
} catch (Exception e) {
System.out.println("catch");
e.printStackTrace();
}
finally {
System.out.println("finally");
return "finally";
}
}
}
如果try中有return那么finally中不要有return不然不会执行try中的return
猜你喜欢
转载自www.cnblogs.com/honghong75042/p/11578874.html
今日推荐
周排行