Array - waveprint column wise

while compling output is perfectly coming but when i submitted the code it does’nt pass any test case show 0

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int M = sc.nextInt();
int N = sc.nextInt();
//declare the array
int [][] arr = new int[M][N];
for(int i=0;i<=arr.length-1;i++){
arr[i] = new int[N];
for(int j=0;j<=arr.length-1;j++)
{
arr[i][j] = sc.nextInt();
}
System.out.println();
}
WaveColumn(arr);
}
public static void WaveColumn(int [][] arr)
{
for(int j=0; j<=arr.length-1;j++)
{
if(j%2==0)
{
for(int i=0; i<=arr[j].length-1;i++)
{
System.out.print(arr[i][j]+ ", ");
}

		}
		else
		{
			for(int i=arr[j].length-1;i>=0;i--)
			{
				System.out.print(arr[i][j]+ ", ");
			}
		}
	}
	System.out.print("END");
}

}
this is my code

@Naman_Gupta,
https://ide.codingblocks.com/s/254781 corrected code. I have commented the errors and corrected them.

Also,
For the input:
2 3
1 2 3
4 5 6
Your code gives run time error.

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.