*
 *
  *
   *
    *
                        public class StarPattern9
{
    public static void main(String[] args)
    {
        for (int i=1; i<=5; i++)
        {
            for (int j=1; j<=i; j++)
            {
                if(i==j)
                {
                    System.out.print("*");
                }
                else
                {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}
                                
                            * * * * *
public class StarPattern9
{
    public static void main(String[] args)
    {
        for (int i=1; i<=5; i++)
        {
            for (int j=5; j>=i; j--)
            {
                if(i==j)
                {
                    System.out.print("*");
                }
                else
                {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}
                                
                            
            Your feedback helps us grow! If there's anything we can fix or improve, please let us know. 
            We’re here to make our tutorials better based on your thoughts and suggestions.