代码:

package test;

public class FinallyTest {

    public static void main(String[] args) {

        try {
            // process try

//            return;
//            System.exit(0);
        } catch (Exception e) {
            // process catch
        } finally {
            // process finally
        }

    }
}

 

如果try里面执行的是return,则finally块会执行

如果try里面执行的是exit,则finally块不会执行

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2018-03-24
  • 2021-05-17
  • 2021-06-19
  • 2021-11-02
  • 2022-12-23
猜你喜欢
  • 2021-12-29
  • 2022-12-23
  • 2021-11-09
  • 2021-06-18
  • 2021-05-18
  • 2021-06-28
  • 2022-12-23
相关资源
相似解决方案