squareboard.java

来自「tutorial solutions for java programing」· Java 代码 · 共 15 行

JAVA
15
字号
// Exercise 3.6
public class SquareBoard { // Saved as "SquareBoard.java"
	public static void main (String[] args) {
		int size = 5; //the size of the square board
		
		//print the board using 2 For loops
		for (int row = 0; row <= size; row++) {// print the row of the board
			for (int col = 0; col <= size; col++) {// print the col of the board
				System.out.print("# "); // print without newline
			}//all together print 5(size) "#"s at the end of the inner loop
			System.out.println(); // for printing newline
		}//all together print 5(size) lines at the end of the outer loop
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?