ITeye博客

关于java中关于switch的一个注意点

寻梦者 · 2012-11-08 13:01 · javaBase · 编程语言 · Markdown

public class TestSwitch {

 

    public static void main(String[] args) {

        System.out.println(getSwitchValue(3));

    }

 

   public static  int getSwitchValue(int num){

       switch (num) {

        case 1:

            return 1;

        case 2:

            return 2;

        case 3:

        case 4:

        case 5:

            return 5;

        default:

            break;

 

    }

       return 88;    

   }

}

 

 

结果: 5

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。