내가 가진 오전 LinkedList
로 -NULL 문자열로 모든 요소가 포함되어 있는지 여부를 확인하는 방법?
List<String> tables = new LinkedList<String>();
때때로, tables
목록은 그 안에 모든 널 (null) 문자열 값이됩니다 의미처럼 보일 것 -
[null, null]
을 식별하는 직접적인 방법이 있나요 tables
목록에 null
문자열과 같은 모든 요소가 있으면 true를 반환하고 그렇지 않으면 false를 반환합니다.
내가 생각할 수있는 한 가지 방법은 그냥 반복하여 계속해서 null 문자열이 있는지 여부를 확인한 다음 그에 따라 true 또는 false를 반환하는 것입니다.
UPDATE : -
public static void main(String[] args) {
String table_1 = null;
String table_2 = "hello";
List<String> tables = new LinkedList<String>();
tables.add(table_1);
tables.add(table_2);
boolean ss = isAllNull(tables);
System.out.println(ss);
}
public static boolean isAllNull(Iterable<?> list) {
for (Object obj : list) {
if (obj != null)
return false;
}
return true;
}
을 당신이 생각하는 방법은 올바른 길. –