在catch中使用throw,finally中的语句是否会执行?
public class Exceptiontest
{
?? public static void main(String[] args) throws Exception
?? {
??? try{
???? System.out.println("zai try中");
??? }catch(Exception e){
???? System.out.println("zai catch中");
???? throw new Exception("在catch中的throw");
??? }finally{
???? System.out.println("zai finally");
??? }
?? }
}
执行结果是:
zai try中
zai finally
说明:尽管在catch中使用throw,程序依然会执行finally中的语句