Creation of hollow triangle
Here we have created a 6 row hollow triangle with * symbol with the for loop
The first for loop is for row creation
for(int i=1;i<=n;i++)
The second for loop is for column
for(int j=1;j<=m-1;j++)
The third for loop is for display of *
for(int k=1;k<=2*i-1;k++)
Since we are creating a hollow pyramid we take onlt first column and last column into consideration
And also the last row.
if(k==1 || (k==2*i-1 || i==n))
System.out.print("*");
All the remaining elements of the rows and columns are left empty
else
System.out.print(" ");
A new line is started after every row
System.out.print("\n");