Wave Print Row wise

Whats Wrong in this code Why test case are going wrong.

import java.util.*;
public class WavePrintRowWise {

public static void main(String[] args) {
 	  
       Scanner sc=new Scanner(System.in);
       System.out.print("");
       int M=sc.nextInt();
       int N=sc.nextInt();
       
       System.out.print("");    
        
       int [][] arr=new int[M][N];
        
          
        for(int i=0; i<M;i++)
         {            
            for(int j=0; j<N;j++)
            {
                arr[i][j]=sc.nextInt();
            }
         }
printRowWise(arr);
}

public static void printRowWise(int[][] arr) {
for(int i=0;i<arr.length;i++) {
if(i%2==0) {
for(int j=0;j<arr[i].length;j++) {
System.out.print(arr[i][j]+",");
}
}else {
for(int j=arr[i].length-1;j>=0;j–) {
System.out.print(arr[i] [j]+",");
}
}
}
System.out.print(β€œEND”);
}
}

corrected code:


always follow the output format