用java编写一个应用程序,将下列图形界面在屏幕中显示出来。 * *** ***** *******
时间: 2023-11-24 15:07:58 浏览: 140
Java图形界面程序单选按钮、复选框、文本框、标签程序设计举例.pdf
以下是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();
}
}
}
```
阅读全文