Java switch语句

Java switch语句

 

package cn.geekeryi;

public class SwitchTest {
    public static void main(String[] args) {
        int grade = 2;
        if (grade==1){
            System.out.println("大一,爱上大学");
        }else if (grade==2){
            System.out.println("大二,开始撩妹");
        }else if (grade==3){
            System.out.println("大三,女友怀孕");
        }else{
            System.out.println("大四,毕业生子");
        }
        switch(grade){
            case 1:
                System.out.println("大一,爱上大学");
                break;
            case 2:
                System.out.println("大二,开始撩妹");
                break;
            case 3:
                System.out.println("大三,女友怀孕");
                break;
            default:
                System.out.println("大四,毕业生子");
                break;

        }
    }
}

  

posted @ 2020-07-21 19:08  极客易先生  阅读(198)  评论(0编辑  收藏  举报