1
2
3
4
5
6
7
8
9
10
11
|
Map[]resultList = (Map[])testService.selectTable(params);
boolean isResultListCheck = Arrays.asList(resultList).subList(0, 4).contains(null);
// resultList에 null이 없을 경우
// isResultListCheck 의 return값 = false
// resultList = [null, null, null, null, null]일 경우
// isResultListCheck 의 return값 = true
// subList(시작인덱스 값, 종료 인덱스값) // array에서 null이 있는지 체크할 인덱스 범위만큼 설정하면 된다. |
cs |
* 출처 : https://stackoverflow.com/questions/4729792/detect-null-reference-in-an-array
Detect null reference in an array
I want to detect whether or not a subrange of an array contains the null reference. Somehow like this: public static boolean containsNull (T[] array, int fromInclusive, int toExclusive) ...
stackoverflow.com