└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # To-print-program-in-x-pattern- 2 | 3 | Program 4 | 5 | public class Main{ 6 | public static void main(String[] args) { 7 | printXPattern("Program"); 8 | } 9 | 10 | public static void printXPattern(String word) { 11 | int length = word.length(); 12 | 13 | for (int i = 0; i < length; i++) { 14 | for (int j = 0; j < length; j++) { 15 | if (i == j || j == length - i - 1) { 16 | System.out.print(word.charAt(j)); 17 | } else { 18 | System.out.print(" "); 19 | } 20 | } 21 | System.out.println(); 22 | } 23 | } 24 | } 25 | --------------------------------------------------------------------------------