java里的switch循环--你妹考试落榜了

总结:switch循环,不用break。那么程序每一个case都会运行到,直到遇到break停止

package com.aa;

//格子区域
//3行3列的格子
public class Bu {

	public static int Bu(int x) {
		int j = 1;
		switch (x) {
		case 1:
			j++;
		case 2:
			j++;
		case 3:
			j++;
		default:
			j++;

		}
		return j + x;
	}

	public static void main(String[] args) {
		System.out.println(Bu(2));
	}
}
//
6

  

原文地址:https://www.cnblogs.com/langlove/p/3458475.html