Hi Guys,

In this post, our intention is to create Z Pattern (see below).  Already in our previous posts, we learnt X and Y Patterns.  Here our focus would be on creating the below pattern.

Z

package pattern.aug;

public class ZPattern {

public static void main(String[] args) {
// TODO Auto-generated method stub
//1st line
for(int i=0;i<5;i++)
{
System.out.print(“*”);
}

System.out.println();

//2nd line
for(int i=0;i<3;i++)
{
System.out.print(” “);
}
System.out.print(“*”);
System.out.println();

//3rd line
for(int i=0;i<2;i++)
{
System.out.print(” “);
}
System.out.print(“*”);
System.out.println();

//4th line
for(int i=0;i<1;i++)
{
System.out.print(” “);
}
System.out.print(“*”);
System.out.println();

//5th line
for(int i=0;i<5;i++)
{
System.out.print(“*”);
}
}
}

Output: 

Z