Print Alphabet Pattern in Java


Prev Tutorial Next Tutorial

Java Program to Print Alphabet Pattern

In Java language you can easily print alphabet pattern using for loop and also using while loop, here i will show you in simple way to print these all patterns.

Print Alphabet Pattern in Java

class AlphabetsDemo
{
   public static void main(String args[])
   {
      char ch;
 
      for( ch = 'a' ; ch <= 'z' ; ch++ )
         System.out.println(ch);
   }
}

Output

 a
 b
 c
 d
 e
 .
 .
 .
 z

Alphabet Pattern in Java

class AlphabetsPattern
{
  public static void main(String abc[])
  {
   for(int i=1;i<5;i++)
   {
   int alphabet=65;                          //ASCII value of A
   for(int j=1;j<=i;j++)
   {
   System.out.print((char)alphabet);
   alphabet++;
   }
   System.out.println();
   }
  }
}

Output

A
AB
ABC
ABCD

Java Program to Print Alphabet Pattern

class AlphabetPattern
{
 public static void main(String abc[])
{
 int alphabet=65;                          //ASCII value of A
 for(int i=1;i<5;i++)
 {            
 for(int j=1;j<=i;j++)
 {
 System.out.print((char)alphabet);
 alphabet++;
 }
 System.out.println();
 }
}
}

Output

 A
BC
DEF
GHIJ

Java Program to Print Alphabet Pattern

class AlphabetPattern
{
 public static void main(String abc[])
 {
 int alphabet=65;
 for(int i=1;i<5;i++)
 {
 for(int j=1;j<=i;j++)
 {
 System.out.print((char)alphabet);
 }
 System.out.println();
 alphabet++;
 }
 }
}

Output

A
BB
CCC
DDDD

Print Alphabet Pattern in Java

class PrintAlphabetPattern
{
public static void main(String abc[])
{
for(int i=1;i<10;i++)  // increase count 10 to 27 to print till "z"
{           
 String strChars="";   
 int alphabet=97;                          //ASCII value of A = 65 and a=97
 for(int j=1;j<=i;j++)
 { 
 strChars=strChars+(char)alphabet + " + ";
 alphabet++;
 }  
 System.out.println("(" + strChars.substring(0,strChars.length()-3) + ")");
 }
}
}

Output

 (a)
(a + b)
(a + b + c)
(a + b + c + d)
(a + b + c + d + e)
(a + b + c + d + e + f)
(a + b + c + d + e + f + g)
(a + b + c + d + e + f + g + h)
(a + b + c + d + e + f + g + h + i)

Prev Tutorial Next Tutorial

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements