public class Demo8 {
public static void main(String[] args) {
for (int i = 1; i <= 3; i++) {
// 内层空格
for (int j = 1; j <= (3 - i); j++) {
System.out.print(" ");
}
//内层有*
for (int m = 1; m <= 2 *i -1; m++) {
System.out.print("*");
}
System.out.println("");//换行
}
}
}
二重循环
for{//外层控制打印多少行
for{内行控制打印多少列
}
}
public class Demo7 {
public static void main(String[] args) {
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");//每行打印多少个(j<=i)
}
System.out.println("");//换行
}
}
}
public class Demo6 {
public static void main(String[] args) {
for(int i = 1; i<=4;i++) {
for(int j = 1; j<=4;j++) {
System.out.print("*");
}
System.out.println("");
}
}
}