Java switch语句第二种用法

Java switch语句第二种用法

package cn.geekeryi;

public class SwitchTest02 {
    public static void main(String[] args) {
        short month = 1;
        if (month==1||month==2||month==3){
            System.out.println("这是一季度");
        }else if (month==4||month==5||month==6){
            System.out.println("这是二季度");
        }else if (month==7||month==8||month==9){
            System.out.println("这是三季度");
        }else {
            System.out.println("这是四季度");
        }
        switch(month){
            case 1:
            case 2:
            case 3:
                System.out.println("这是1季度");
                break;
            case 4:
            case 5:
            case 6:
                System.out.println("这是2季度");
                break;
            case 7:
            case 8:
            case 9:
                System.out.println("这是3季度");
                break;
            default:
                System.out.println("这是4季度");
                break;

        }
    }
}

  

原文地址:https://www.cnblogs.com/yigongzi/p/13357008.html