1import java.util.ArrayList;
2public class ArrayListContainsAllMethodExample
3{
4 public static void main(String[] args)
5 {
6 ArrayList<String> al1 = new ArrayList<String>();
7 al1.add("red");
8 al1.add("green");
9 al1.add("blue");
10 System.out.println("ArrayList 1: " + al1);
11 // creating another ArrayList
12 ArrayList<String> al2 = new ArrayList<String>();
13 // adding elements to second ArrayList
14 al2.add("blue");
15 al2.add("green");
16 System.out.println("ArrayList 2: " + al2);
17 // checking if ArrayList 1 contains ArrayList 2
18 boolean output1 = al1.containsAll(al2);
19 System.out.println("Does ArrayList 1 contains all elements of ArrayList 2?: " + output1);
20 // checking if ArrayList 2 contains ArrayList 1
21 boolean output2 = al2.containsAll(al1);
22 System.out.println("Does ArrayList 2 contains all elements of ArrayList 1?: " + output2);
23 }
24}