LillianEom
2/25/2018 - 7:35 AM

获取二维数组的维度

int[][] matrix;

/* 异常情况:null [] [[]]
** 否则matrix[0]会出现空指针的错误
*/
if (matrix == null || matrix.length == 0) {
    return false;
}
if (matrix[0] == null || matrix[0].length == 0) {
    return false;
}
int m = matrix.length;
int n = matrix[0].length;