Following is the code for pyramid pattern:
import java.util.*;
public class Pattern
{
public static void main(String[] nt)
{
Scanner in=new Scanner(System.in);
System.out.println("Enter Number of rows");
int x=in.nextInt();
int a=x+5;
System.out.println("Pattern is");
for(int i=1;i<=x;i++)
{ for(int j=a;j!=0;j--)
{
System.out.print(" ");
}
for(int j=1;j<=i;j++)
{
System.out.print(i+" ");
}
System.out.println();
a--;
}
}
}
import java.util.*;
public class Pattern
{
public static void main(String[] nt)
{
Scanner in=new Scanner(System.in);
System.out.println("Enter Number of rows");
int x=in.nextInt();
int a=x+5;
System.out.println("Pattern is");
for(int i=1;i<=x;i++)
{ for(int j=a;j!=0;j--)
{
System.out.print(" ");
}
for(int j=1;j<=i;j++)
{
System.out.print(i+" ");
}
System.out.println();
a--;
}
}
}
Output: