Sir please explain me what is error in this code. It shows error when i compile it
import java.util.Scanner;
public class Search2DArray {
public static void main(String[] args) {
int[][] array = {
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 }
};
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the element to search: ");
int target = scanner.nextInt();
boolean found = false;
int row = -1;
int column = -1;
// Iterate through the array and search for the element
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
if (array[i][j] == target) {
found = true;
row = i;
column = j;
break;
}
}
}
// Display the search result
if (found) {
System.out.println("Element found at row " + row + ", column " + column);
} else {
System.out.println("Element not found");
}
scanner.close();
}
}