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.
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