在try-catch-finally语句中使用return语句遇到了一些疑问

代码一:

static int intc(){
        int x =0;
        try{
            x=1;
            return x;
        }finally {
            x = 3;  
        }
    }

代码二:在上面那段代码的finally语句中加入了return语句

static int intc(){
        int x =0;
        try{
            x=1;
            return x;
        }finally {
            x = 3;
            return x;
        }
    }

代码三:

static int intc(){
        int x =0;
        try{
            x=1;
            return x;
        }finally {
            x = 3;
            return 0;
        }
    }

那么这三个方法的执行结果是多少呢?

代码一:返回1;
代码二:返回3;
代码三:返回0;
View Code

相关文章:

  • 2022-02-04
  • 2021-08-02
  • 2021-05-31
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-10-07
猜你喜欢
  • 2022-12-23
  • 2021-07-10
  • 2021-08-16
  • 2022-01-14
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案