Java中AbstractSequentialList的containsAll()方法
AbstractSequentialList的containsAll()方法检查此集合中的所有元素。如果此集合包含指定集合中的所有元素,即这两个集合相同时,它将返回TRUE。
语法如下
public boolean containsAll(Collection<?> c)
其中,c是要检查的集合
要使用Java中的AbstractSequentialList类,您需要导入以下包
import java.util.AbstractSequentialList;
下面是使用Java中的AbstractSequentialList containsAll()方法的示例
示例
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); absSequential.add(66); absSequential.add(99); absSequential.add(140); absSequential.add(270); absSequential.add(360); absSequential.add(490); System.out.println("Elements in the AbstractSequentialList1 = "+absSequential); AbstractSequentialList<Integer> absSequential2 = new LinkedList<>(); absSequential2.add(66); absSequential2.add(99); absSequential2.add(140); absSequential2.add(270); absSequential2.add(360); absSequential2.add(490); System.out.println("Elements in the AbstractSequentialList2 = "+absSequential2); System.out.println("Both are same? = "+absSequential.containsAll(absSequential2)); } }
输出
Elements in the AbstractSequentialList1 = [66, 99, 140, 270, 360, 490] Elements in the AbstractSequentialList2 = [66, 99, 140, 270, 360, 490] Both are same? = true
广告