Print Alphabet Pattern in Java

Advertisements

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. ABCDEFJHI Alphabet Pattern in Java

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 Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements