Porblem print wave column wise

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int m = cin.nextInt(), n = cin.nextInt(), arr[][] = new int[m][n];
for(int i = 0;i<=m-1;i++){
for(int j =0;j<=n-1;j++){
arr[i][j] = cin.nextInt();
}
}
for(int j = 0;j<=n-1;j++){
if(j%2 == 0){
for(int i = 0;i<=n-1;i++){
System.out.print(arr[i][j]+", β€œ);
}
}else{
for(int i = n-1;i>=0;i–){
System.out.print(arr[i][j]+”, ");
}
}

	}
	System.out.print("END");
}

}======what’s the error

hi @AbhishekAhlawat1102
you have to use m here instead of n
if(j%2 == 0){
for(int i = 0;i<=n-1;i++){
System.out.print(arr[i][j]+", β€œ);
}
}else{
for(int i = n-1;i>=0;i–){
System.out.print(arr[i][j]+”, ");
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.