public class Solution {

```
public int kthSmallest(int[][] matrix, int k) {
int i = 0;
int[] list = new int[(matrix.length) * (matrix.length)];
while(i< matrix.length){
int j = 0;
while(j< matrix.length){
list[((i) * matrix.length)+j] = matrix[i][j];
j++;
}
i++;
}
Arrays.sort(list);
return list[k-1];
}
```

}