E-Shape Pyramid Program in Java language



package demo;
public class EShape
{
 public static void main(String[] args) 
 {
  int num = 5;
  for (int r = 1; r <= num; r++) 
  {
   if (r % 2 == 0) {
    System.out.print("*");
   } else if (r % 3 == 0) {
    for (int c = 1; c <= r; c++) 
    {
     System.out.print("*");
    }
   } else {
    for (int c = 1; c <= num; c++) 
    {
     System.out.print("*");
    }
   }
   System.out.println();
  }
 }
}

Output:

*****
*
***
*
*****

BUILD SUCCESSFUL (total time: 1 second)