更新时间:2023-12-03 19:56:28
尝试:
tourists.removeAll(Collections.singleton(null));
阅读 Java API.对于不可变列表(例如使用 Arrays.asList
创建),代码将抛出 java.lang.UnsupportedOperationException
;有关详细信息,请参阅此答案.
Read the Java API. The code will throw java.lang.UnsupportedOperationException
for immutable lists (such as created with Arrays.asList
); see this answer for more details.