public class test1 {
public static void main(String[] args){
printRectangle(3,5); //调用printRectangle方法实现打印矩形
printRectangle(2,4);
printRectangle(6,10);
}
public static void printRectangle(int height,int width){
for (int i=0;i<height;i++){ //方法就是一段可以重复调用的代码
for (int j=0;j<width;j++){
System.out.print("*");
}
System.out.println();
}
System.out.println();
}
}
public class test1 {
public static void main(String[] args) {
int area = getArea(3, 5);
System.out.println("The area is " + area);
}
public static int getArea(int height,int width) {
int area = height * width;
return area;
}
}