dimanche 31 mai 2020

How to print a star right triangle in java?

I want to print this in java.

* 
* * 
* * * 
* * * * 
* * * * * 

I have already written this code

class star1
{
    public static void main(String[] args)
    {
        for (int i=0; i<5; i++)
        {
            for (int j=0;j<=i;j++)
            {
                System.out.println("* ");
            }
            System.out.println( );
        }
    }
}

But it does not seem to work

Aucun commentaire:

Enregistrer un commentaire