I need to write a java code that get a 2D array as a matrix and check every rows and columns and find the number that its the max at the rows but the min at the cols.
For example, the 13 is the min at col and max at the row:

I wrote the code but I get lost:
import java.util.Scanner;
public class maxmin {
public static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("enter matrix size ");
int num = input.nextInt();
int num1 = input.nextInt();
maxMin(num, num1);
}
private static void maxMin(int num, int num1) {
int max = 0;
int min = 0;
int[][] matrix = new int[num][num1];
System.out.println("ENTER ARRAY NUMBERS");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].length; j++) {
matrix[i][j] = input.nextInt();
}
}
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[0].length; j++) {
if (matrix[i][j] >= max) {
max = matrix[i][j];
for (int a = 0; a < matrix.length; a++) {
if (matrix[i][a] <= min) {
min = matrix[i][a];
}
if (max == min) {
System.out.println(max);
}
}
}
}
}
}
}