用java编写一个应用程序,将下列图形界面在屏幕中显示出来。 * *** ***** *******
时间: 2023-11-24 16:07:58 浏览: 143
以下是Java代码实现该图形的方法:
```java
public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
for (int k = 4 - i; k >= 1; k--) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
for (int j = 1; j <= 9 - 2 * i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*"); }
for (int k = 4 - i; k >= 1; k--) {
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
```
阅读全文