This is another example of a Java program that prints a pattern of numbers. The program is similar to the previous example, but it prints the numbers in reverse order for each row.
Here’s a breakdown of how the program works:
i
.i
is printed using the System.out.print()
method.System.out.println()
method to move to the next row.class Pattern {
public static void main(String[] args) {
int i, j;
for (i = 1; i <= 8; i++) {
for (j = 8; j >= i; j--) {
System.out.print(i);
}
System.out.println();
}
}
}
11111111
2222222
333333
44444
5555
666
77
8
As you can see, the pattern is the same as the previous example, but the numbers are printed in reverse order for each row.