How do you write simple java program to print equlater star pyramid?

Java

1 answer

Answer

1277743

2026-08-16 02:25

+ Follow

public class StarPyramid

{

public static void main(String [] args)

{

int space = 0, line = 0, star = 0;

for(line = 1; line <= 26; line ++)

{

for(space = 26; space > line; space--)

{

System.out.print(" "); // Display one space

}

for(star = 1; star < line; star++)

{

System.out.print("*‟);

}

for(star = line; star >= 1; star--)

{

System.out.print("*‟);

}

System.out.println(); // Display new line with ln

}

}

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.