问一道JAVA程序。

来源:百度知道 编辑:UC知道 时间:2024/06/12 01:35:41
*
***
*****
***
*
我刚学JAVA,想问下这个该怎么编写程序?

public class Star
{
public static void main(String[] args)
{

for(int h=0;h<=5;h=h+2)
{

for(int u=0;u<6-h;u++)
{
System.out.print(" ");
}
for(int g=5;g>=5-h;g--)
{
System.out.print("*"+" ");
}
System.out.println();

}
for(int i=1;i<=7;i=i+2)
{
for(int j=8-i;j>0;j--)
{
System.out.print("*"+" ");
}
System.out.println();
for(int k=0;k<=i;k++){
System.out.print(" ");
}
}
}
}