
Hi, I want to know how the code to print the pyramid below works. It uses nested for loops.
Pyramid: 1 1234 12 123 123 12 1234 1

Here is the code that will display some pattern of numbers in the form pyramid.
class Pattern
{
public static void main(String[] args){
for(int i=1;i<=4;i++){
for(int j=1;j<=i;j++){
System.out.print(j);
}
System.out.println();
}
System.out.println();
for(int i=4;i>=1;i--){
for(int j=1;j<i+1;j++){
System.out.print(j);
}
System.out.println();
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.