Online Java Compiler By
JavaTpoint.com
import java.util.LinkedList; import java.util.List; public class JavaListContainsAllExample2 { public static void main(String[] args) { List<Integer> list= new LinkedList<>(); for (int i=0;i<11;i++){ list.add(i); } System.out.println("Total elements in the list : "+list); //returns an exception if the specified collection is null Boolean bool=list.containsAll(null); if (bool) { System.out.println("Contains All method will return " + bool); } else{ System.out.println("Contains All method will return " + bool); } } }
Output