Similar Alphabet Pyramid Pattern in Java

In this tutorial, we will write an alphabet triangular pattern in java where the characters or letters are every row have the same alphabet. Before that, you may go through the following topic in java.

Example:

Rows Input: 5
Output:
       A
      B B
     C C C
    D D D D
   E E E E E

Alphabet Pyramid Pattern in Java

import java.util.Scanner;

public class Main
{
  public static void main(String args[])
  {
    int rows, i, j;
    Scanner scan = new Scanner(System.in);

    System.out.print("Enter the number of rows: ");
    rows = scan.nextInt();

    System.out.print("Output:\n");
    for (i = 1; i <= rows; i++)
    {
      for (j = 1; j <= rows - i; j++)
        System.out.print(" ");

      for (j = 1; j <= i; j++)
        System.out.print((char)(char)(i + 64) + " ");

      System.out.println();
    }
  }
}

Output:

Enter the number of rows: 8
Output:
       A
      B B
     C C C
    D D D D
   E E E E E
  F F F F F F
 G G G G G G G
H H H H H H H H