Simple Java Program to print Stars!

Here is a very simple pure java program to print stars in the shape of a right-angle triangle. Almost like a half pyramid.

public class javastar {
    public static void main(String[] args) 
    {
         int z=1; 
         for(int i=0;i<5;i++)
        {
            for(int k=0;k<z;k++)
            {
                System.out.print("*");
            }
            z=z+2;
            System.out.println();  
        }

    }
}

Leave a Reply

Theme: Overlay by Kaira
Agurchand