博主使用了两种方法实现:
public class first_homework {
public static void main(String args[]) {
System.out.println("*");
System.out.println("**");
System.out.println("***");
System.out.println("****");
}
}
运行结果:

使用第二种方法:
public class first_homework_2 {
public static void main(String args[]) {
for(int i=1;i<=4;i++) {
for(int j=i;j>0;j--) {
System.out.print("*");
}
System.out.println(" ");
}
}
}
结果一样。
1万+

被折叠的 条评论
为什么被折叠?



