🪔 शुभ नवरात्रि!    Use Code: FESTIVALOFF300    Invoke the power of knowledge – Get ₹300 to ₹800 OFF on Java Courses 🎊
Celebrate & Learn 🙏

Full Pyramid Star Pattern Program in Java  


Program:
    *
   ***
  *****
 *******
*********
  • There are 2 solutions for this program :-
  • Program 1:
    public class StarPattern8
    {
        public static void main(String[] args)
        {
            for (int i=1; i<=5; i++)
            {
                for(int j=4; j>=i; j--)
                {
                    System.out.print(" ");
                }
                for (int k=1; k<=i; k++)
                {
                    System.out.print("*");
                }
                for(int l=2; l<=i; l++)
                {
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }
  • Program 2:
    public class StarPattern8
    {
        public static void main(String[] args)
        {
            for (int i=1; i<=5; i++)
            {
                for(int j=4; j>=i; j--)
                {
                    System.out.print(" ");
                }
                for (int k=1; k<=(2*i-1); k++)
                {
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }