My Code is compile successfully and it gives desired output but when i submit code all test cases fail

import java.util.*;
public class Main {
public static void printWave(int[][] arr) {
for (int row = 0; row < arr.length; row++) {
if(row%2==0) {
for (int col = 0; col < arr.length; col++) {
System.out.print(arr[row][col]+", “);
}
}
else {
for (int col = arr.length-1 ; col >= 0; col–) {
System.out.print(arr[row][col]+”, ");
}
}
}
System.out.println(“END”);
}

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	// enter no of rows

int rows = sc.nextInt();
    int cols = sc.nextInt();
	int[][] arr = new int[rows][cols];

	for (int row = 0; row < arr.length; row++) {
		// enter size for coloum row 0 , 1 , 2 ,
		
		// enter value for colom 0,1,2,3
		for (int col = 0; col < cols; col++) {
			arr[row][col] = sc.nextInt();
		}

	}

	printWave(arr);

}
}

hey @nigamshubham1998 inside printWave function
just change in inner for loop
for (int col = 0; col < arr[0].length; col++)
also here
for (int col = arr[0].length - 1; col >= 0; col–)

thanks alot problem solved

@nigamshubham1998 Please mark your doubts as resolved in your course’s.
and please rate your experience here