
Welcome EveryOne , I have the progrem of apatten But have Errors within the program :
public class pattern {
public static void main(String[]args){
displaypattern(7);
}
public static void displaypattern(int n){
for(int rows=1;row <=n;row++){
//print space
for(int i=row;i<n;i++)
System.out.print(" ");
//print numbers
for(int i=row;i>=1;i--)
System.out.print(" "+i);
System.out.println();
}
}
}
So Do you know what are the mistakes ?

We have modified your code.
public class pattern {
public static void main(String[]args){
displaypattern(7);
}
public static void displaypattern(int n){
for(int row=1;row <=n;row++){
//print space
for(int i=row;i<n;i++)
System.out.print(" ");
//print numbers
for(int i=row;i>=1;i--)
System.out.print(" "+i);
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.