java中条件的使用之switch语句

条件的使用,通过自己输入的值打印对应所需

public class Test {
    
    private static void t3() {
        int num = 2;
        switch (num){
            case 1:
                System.out.println("1111");
                break;
            case 2:
                System.out.println("2222");
                break;
            default:
                System.out.println("0000");
        }
    }
 
    public static void main(String[] args) {
        t3();
        
    }
 
}

猜你喜欢

转载自blog.csdn.net/m0_59186440/article/details/121997704