public final class A { public void mySwitch(int type){ switch(type){ case 1: System.out.println(1); default: System.out.println(type); case 2: System.out.println(2); case 3: System.out.println(3); } } public static void main(String[] args) { // TODO Auto-generated method stub new A().mySwitch(4); } }
返回结果:
4 2 3