I'm getting correct output on ECLISPE but on online submission getting run error

package challenges_CB_2;

import java.util.Scanner;

public class Wave_print {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();

int a [][] = new int[n][m];
for(int i=0; i<n;i++) {
	for(int j =0; j<m; j++) {
		
		a[i][j] = sc.nextInt();
		
		}
		
	}

printWave(a);

}

public static void printWave(int[][]a) {

for(int row = 0;row<a.length;row++) {
	
	if(row%2==0) {
		for(int k =0 ; k<a[row].length;k++) {
			System.out.print(a[k][row]+", ");
		}
	}else {
			for(int k = a[row].length-1;k>=0;k--) {
				System.out.print(a[k][row]+", ");
			}
		}
	}
	System.out.println("END");

}

}

see the changes which i have made

public static void printWave(int[][]arr) {

	  for(int c=0;c<arr[0].length;c++){
		  if(c%2==0){
			  for(int r=0;r<arr.length;r++){
				  System.out.print(arr[r][c]+", ");
			  }
		  }else{
              for(int r=arr.length-1;r>=0;r--){
				  System.out.print(arr[r][c]+", ");
			  }
		  }
	  }
	  System.out.println("END");
  }

hope this will help u
pls rate my work so that i can improve myself.