小程序之switch...case...break

猜猜这段小程序会打印出什么结果?

public class Test {

    public static void main(String[] args) {
        int i = 2;
        decide(i);

    }

    public static void decide(int i){
        switch (i) {
        case 1:
            System.out.print("-----------1------------");
        case 2:
            System.out.print("-----------2------------");
        case 3:
            System.out.print("-----------3------------");
        case 4:
            System.out.print("-----------4------------");
            break;
        default:
            System.out.print("-----------default------------");
            break;

        }
    }

}

你可能感兴趣的:(Android,Meditation,Android归纳)