[@小川游鱼][¥20]try catch finally,try里有return,finally还执行么?
执行的
public static void main(String[] args) {
try {
String str = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss.SSS Z',
Locale.ENGLISH).format(new Date());
System.out.println(str);
return;
} catch (Exception e) {
System.out.println('Exception!');
} finally {
System.out.println('Finally!');
}
}
输出:
2019-01-14 17:05:23.169 +0800Finally!
执行的
public static void main(String[] args) {
try {
String str = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss.SSS Z',
Locale.ENGLISH).format(new Date());
System.out.println(str);
return;
} catch (Exception e) {
System.out.println('Exception!');
} finally {
System.out.println('Finally!');
}
}
输出:
2019-01-14 17:05:23.169 +0800Finally!
执行的
赞0
踩0