Write a Java program to print triangle of mirrored numbers pattern using for loop.
package Shapes3; import java.util.Scanner; public class TriangleMirroredNum1 { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); System.out.print("Enter Traingle Mirrored Numbers Rows = "); int rows = sc.nextInt(); System.out.println("Printing Traingle of Mirrored Numbers Pattern"); for (int i = 1; i <= rows; i++ ) { for (int j = rows; j > i; j-- ) { System.out.print(" "); } for(int k = 1; k <= i; k++) { System.out.print(k); } for(int l = i - 1; l >= 1; l--) { System.out.print(l); } System.out.println(); } } }

This Java pattern example prints the triangle of mirrored numbers using while loop.
package Shapes3; import java.util.Scanner; public class TriangleMirroredNum2 { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); System.out.print("Enter Traingle Mirrored Numbers Rows = "); int rows = sc.nextInt(); System.out.println("Printing Traingle of Mirrored Numbers Pattern"); int j, k, l, i = 1; while(i <= rows) { j = rows; while(j > i) { System.out.print(" "); j--; } k = 1; while(k <= i) { System.out.print(k); k++; } l = i - 1; while(l >= 1) { System.out.print(l); l--; } System.out.println(); i++; } } }
Enter Traingle Mirrored Numbers Rows = 9
Printing Traingle of Mirrored Numbers Pattern
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321