Hey I am getting wrong one test case. Can Anyone help?

import java.util.*;

public class Main {

public static void main(String args[]) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();

    int m = scan.nextInt();

    int[][] matrix = new int[n][m];

    for(int i=0;i<n;i++){

        for(int j=0;j<m;j++)matrix[i][j] = scan.nextInt();

    }

    int top = 0;

int left = 0;

int right = matrix[0].length -1;

int bottom = matrix.length - 1;

int dir = 0;

while(top < bottom && left < right){

switch(dir){

case 0:

for(int i = top;i<=bottom;i++){

System.out.print(matrix[i][left] + ", ");

}

left++;

dir++;

case 1:

for(int i=left;i<=right;i++){

System.out.print(matrix[bottom][i] + ", ");

}

bottom–;

dir++;

case 2:

for(int i=bottom;i>=top;i–){

System.out.print(matrix[i][right] + ", ");

}

right–;

dir++;

case 3:

for(int i =right;i>=left;i–){

System.out.print(matrix[top][i] + ", ");

}

top++;

dir = 0;

}

}

    System.out.print("END");

}

}