Matrix search : run error?

what is he problem and is there any other way for sorted matrix???

import java.util.Scanner;

public class Main {

static Scanner scn = new Scanner(System.in);

public static void main(String[] args) {
	int testCases = scn.nextInt();
	while (testCases > 0) {
		int[][] array = takeInput();
		//display(array);
		//element to be searched
		//int[][] array = { { 11, 12, 13, 14 }, { 21, 22, 23, 24 }, { 31, 32, 33, 34 }, { 41, 42, 43, 44 } };
		//display(array);
		int x = scn.nextInt();
		int ans = linearSearch(array,x);
		System.out.println(ans);
		testCases--;
	}

// int[][] array = { { 11, 12, 13, 14 }, { 21, 22, 23, 24 }, { 31, 32, 33, 34 }, { 41, 42, 43, 44 } };
// display(array);

}

public static int[][] takeInput() {
	//System.out.println("Enter no of rows");
	// here rows =n, columns = m
	int n = scn.nextInt();
	int m = scn.nextInt();
	
	int[][] arr = new int[n][m];
	for (int row = 0; row < n; row++) {
		for (int col = 0; col < m; col++) {
			arr[row][col] = scn.nextInt();
		}
	}
	return arr;
}

public static void display(int[][] arr) {
	for (int i = 0; i < arr.length; i++) {
		for (int j = 0; j < arr[i].length; j++) {
			System.out.print(arr[i][j] + " ");
		}
		System.out.println();
	}
}

public static int linearSearch(int[][] arr, int x) {
	int ans = 0;//initially no element found
	for (int i = 0; i < arr.length; i++) {
		for (int j = 0; j < arr[i].length; j++) {
			if(arr[i][j] == x) {
				ans = 1;
			}
		}
	}
	return ans;
}

}

Please share link to the exact question and save your code on online ide https://ide.codingblocks.com/
and then share its link.
In case for sorted matrix, an algorithm with complexity O(n) is possible. Think over it.

Hey Abhishek, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.