Tuesday, 2 February 2016

Star Pattern in Java | Print Triangle of star in Java

Print Star Pattern in Java

Hello, today we write for for print Star Pattern in Java. This is very simple you need to follow C language concept to print triangle of star only change syntax of C programming to Java syntax programming.

Print Star Pattern in Java

Code to print Star pattern Program in Java:

class StarsPattern
{
 public static void main(String[] args)
{
 int row, numberOfStars;
 for (row = 1; row <=5; row++)
{
 for(numberOfStars = 1; numberOfStars <= row; numberOfStars++)
 {
 System.out.print("*");
 }
 System.out.println(); // Used for Go to next line
 }
 }
 }

Output:

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

No comments:

Post a Comment