首页 > 其他 > 详细

有关异常的趣味题,欢迎来战!!!!!

时间:2019-12-02 18:56:18      阅读:63      评论:0      收藏:0      [点我收藏+]

public class Test {

public static void main(String[] args) {

           System.out.println(test4());

           System.out.println("y = " + y);
}

public static String test4() {
               String aa = "aa";
         try {
                  aa = "bb";
                  return aa;
            } catch (Exception e) {
                 e.printStackTrace();
           } finally {
                aa = "cc";
          }
           return aa;

}

 

********************************************************************************************************************************************************************************************

 

public class Test {

public static void main(String[] args) {

    int y = test5();

}


public static int test5() {
           int x = 1;
       try {
                    System.out.println("A");
                    return ++ x;
            } catch (Exception e) {
                    System.out.println("D");
           } finally {
                    System.out.println("B");
                   ++x;
         }
          System.out.println("C");
          return x;
    }

 

 

 

 

 

有关异常的趣味题,欢迎来战!!!!!

原文:https://www.cnblogs.com/suger-4/p/11972431.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!