19 lines
479 B
Java
19 lines
479 B
Java
package chapter2;
|
||
|
||
public class Example19 {
|
||
public static void main(String[] args) {
|
||
printRectangle(3, 5);
|
||
}
|
||
|
||
// 下面定义了一个打印矩形的方法,接收两个参数,其中height为高,width为宽
|
||
public static void printRectangle(int height, int width) {
|
||
// 下面是使用嵌套for循环实现*打印矩形
|
||
for (int i = 0; i < height; i++) {
|
||
for (int j = 0; j < width; j++) {
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|