In this tutorial, we will go through alphabet pattern programs in java programming. Before that, you may go through the following topic in java.
Half Repeated Character Pattern in Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import java.util.Scanner; public class Main { public static void main(String args[]) { int rows, i, j, k; Scanner sc = new Scanner(System.in); System.out.print("Enter the no. of rows: "); rows = sc.nextInt(); for (i = 0; i <= rows; i++) { int alphabet = 65; for (j = 0; j < i; j++) System.out.print(" "); for (k = i; k <= rows; k++) System.out.print((char)(alphabet + k)); System.out.println(); } for (i = rows; i >= 0; i--) { int alphabet = 65; for (j = 0; j < i; j++) System.out.print(" "); for (k = i; k <= rows; k++) System.out.print((char)(alphabet + k)); System.out.println(); } } } |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 | Enter the no. of rows: 5 ABCDEF BCDEF CDEF DEF EF F F EF DEF CDEF BCDEF ABCDEF |