如果
我的计算得到了AssertionError。
public boolean subListNullCheck (ArrayList<ArrayList<Integer>> list, int j) {
if(list == null || list.isEmpty() || list.get(0).isEmpty() ) {
return false;
} if(list.contains(j)) {
return true;
}
return false;
}
list
包含值j
,则list.contains(j)
返回true
,而不是如果索引j
处的元素不为null。
你可以写:
public boolean subListNullCheck (ArrayList<ArrayList<Integer>> list, int j) {
if (list == null) {
return false;
} else if (j >= 0 && list.size > j && list.get(j) != null) {
return true;
}
return false;
}
或者只是
public boolean subListNullCheck (ArrayList<ArrayList<Integer>> list, int j) {
return list != null && j >= 0 &&& list.size > j && list.get(j) != null;
}