In this tutorial, we will write a Java program to display alphabet pyramid patterns. Before that, you may go through the following topic in java.
We will look at pyramid patterns in java using alphabets/letters/characters.
Pyramid triangle alphabet
This is a mirror image pattern of letters 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();
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)(j + 64));
for (j = i - 1; j >= 1; j--)
System.out.print((char)(j + 64));
System.out.println();
}
}
}
Enter the number of rows: 6
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
