Home >>Java Programs >Java program to print the following pattern
*
* *
* * *
* * * *
* * * * *
* * * * * *
In this example, we will write a Java program through which we can print the following given pattern on the console.
Algorithm:
class Main
{
public static void main(String[] args)
{
int i,j, n=7;
System.out.println("Right angle triangle");
for(i=1;i<n;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(" *");
}
System.out.println("");
}
}
}