I need to create these patterns in java according to however many lines the user enters:
1
12
123
1234
12345
54321
4321
321
21
1
1
21
321
4321
54321
I can do the first two but I cannot do the third.
Here is the code for the second:
public static void displayPatternII (int lines) {
for (int i = 1; i <= lines; i++){
for (int j = lines + 1 - i; j > 0; j--)
System.out.print (j + " ");
System.out.println();
}
}
1 Answer