Online Java Compiler By
JavaTpoint.com
import java.util.LinkedList; import java.util.List; public class JavaListContainsAllExample3 { public static void main(String[] args) { List
list= new LinkedList<>(); for (int i=0;i<11;i++){ list.add(i); } System.out.println("Total elements in the list : "+list); List
list1= new LinkedList<>(); for (Float i=0.0f;i<11;i++){ list1.add(i); } System.out.println("Total elements in the list1 : "+list1); // returns a Boolean value ?true?, if this list contains all the elements of the invoked collection. Boolean bool=list.containsAll(list1); if (bool) { System.out.println("Contains All method will return " + bool); } else{ System.out.println("Contains All method will return " + bool); } } }
Output