Java中AbstractSequentialList的removeAll()方法
的removeAll()是从类AbstractCollection类继承的方法。它将删除此集合中也包含在指定集合中的所有元素。
语法如下:
public boolean removeAll(Collection<?> c)
在此,参数c是具有要从此集合中删除的元素的集合。
要使用Java中的AbstractSequentialList类,您需要导入以下软件包:
import java.util.AbstractSequentialList;
以下是removeAll()在Java中实现AbstractSequentialList方法的示例:
示例
import java.util.LinkedList;
import java.util.AbstractSequentialList;
public class Demo {
public static void main(String[] args) {
AbstractSequentialList<Integer> absSequential = new LinkedList<>();
absSequential.add(210);
absSequential.add(290);
absSequential.add(350);
absSequential.add(490);
absSequential.add(540);
absSequential.add(670);
absSequential.add(870);
System.out.println("Elements in the AbstractSequentialList1 = "+absSequential);
AbstractSequentialList<Integer> absSequential2 = new LinkedList<>();
absSequential2.add(670);
absSequential2.add(870);
System.out.println("Elements in the AbstractSequentialList2 = "+absSequential2);
absSequential.removeAll(absSequential2);
System.out.println("Elements in the updated AbstractSequentialList1 = "+absSequential);
}
}输出结果
Elements in the AbstractSequentialList1 = [210, 290, 350, 490, 540, 670, 870] Elements in the AbstractSequentialList2 = [670, 870] Elements in the updated AbstractSequentialList1 = [210, 290, 350, 490, 540]
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志