Compilation error

my program is showing no such element expectation error pls correct it
Scanner scn=new Scanner(System.in);
int m=scn.nextInt();
int n=scn.nextInt();
int [][] a=new int[m][n];
int [][] arr= takeInput(a,m,n);
// display(arr,m,n);
printSpiralOrder(a,m,n);
}
public static int[][] takeInput(int[][] a,int m, int n) {
Scanner scn=new Scanner(System.in);
for(int i=0;i<m;i++) {
for(int j=0;j<n;j++) {
a[i][j]=scn.nextInt();
}
}
return a;
}
//public static void display(int[][] arr,int m, int n) {
// for(int i=0;i<m;i++) {
// for(int j=0;j<n;j++) {
// System.out.println(arr[i][j]);
// }
// }
//}
public static void printSpiralOrder(int [][] arr, int m,int n) {
int t=0;
int b=m-1;
int l=0;
int r=n-1;
int dir=0;

while(t<=b &&l<=r) {
	if(dir==0) {
		for(int k=l;k<=r;k++) {
			System.out.println(arr[t][k]);
		}
		t++;dir=1;
		
	}else if(dir==1) {
		for(int k=t;k<=b;k++) {
			System.out.println(arr[k][r]);
		}r--;dir=2;
	}else if(dir==2) {
		for(int k=r;k>=l;k--) {
			System.out.println(arr[b][k]);
			
		}b--;dir=3;
		
	}else if(dir==3) {
		for(int k=b;k>=t;k--) {
			System.out.println(arr[k][l]);
		}l++;dir=0;
		
	}
	
	

}

Hey @Laibaqureshi227
Please Give Custom input

I m giving inputs still i m unable to solve this problem but while solving in Eclipse there is no issue
So will you pls give me complete solution ?

Static scanner will be , dont use 2 scanner ,( get NoSuchElementException )
there’s no benefit to creating more than one Scanner object. It’s simply reading input from a stream, and having more than one reference to that stream isn’t necessary or beneficial to your operations.

Sample Input

4 4
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44

Sample Output

11, 12, 13, 14, 24, 34, 44, 43, 42, 41, 31, 21, 22, 23, 33, 32, END
correct code :

doubt resolved THANK YOU!!