class Pattern
{
public static void main(String args[])
{
//Code for upper triangle
for(int i=1;i<=9;i++)
{
for(int k=9;k>i;k--)//Print Space
{
System.out.print(" ");
}
for(int j=1;j<=i;j++)//Print Left Part
{
System.out.print(" ");
System.out.print(i);
}
for(int j=2;j<=i;j++)//Print Right Part
{
System.out.print(" ");
System.out.print(i);
}
System.out.println();//Print New Line
}
//Code for lower triangle
for(int i=8;i>0;i--)
{
for(int k=i;k<=8;k++)//Print Space
{
System.out.print(" ");
}
for(int j=1;j<=i;j++)//Print Left Part
{
System.out.print(" ");
System.out.print(i);
}
for(int j=2;j<=i;j++)//Print Right Part
{
System.out.print(" ");
System.out.print(i);
}
System.out.println();//Print New Line
}
}
}

 

Output

Pattern_output