java中finally里面的代码一定会执行吗?(try里面做了return呢?)
直接看例子:
public class TryFinallyTest { public static void main(String[] args) { try{ System.out.println("hello finally"); return; }finally { System.out.println("execute finally even try's block has return"); } } }
再看执行结果:
hello finally
execute finally even try's block has return
Process finished with exit code 0