Star Pattern 7 in Java
class Pattern { public static void main(String args[]) { int n = 5; for(int i = n;i >= 1;i--)//This outer loop is for the rows { for(int j = n;j >= i;j--)//This inner loop is for the columns { System.out.print(i+""); } System.out.println(); } } }
Discussion
The logic behind this program is similar to the previous one, just instead of printing the pattern in increasing order, we have just done it in a reverse way.
5
44
333
2222
11111