每当我尝试从List使用list.removeIf(condition)中删除一个元素时,它都会抛出UnsupportedOperationException:
public class Test
{
public static void main(final String[] args)
{
String[] stringArray = new String[]{"A","B","C","D"};
List<String> stringList = Arrays.asList(stringArray);
stringList.forEach(System.out::println);
stringList.removeIf((String string) -> string.equals("B"));
stringList.forEach(System.out::println);
}
}
为什么不起作用?
茅侃侃
临摹微笑
相关分类