How to compare two ArrayList<List<String>>
arraylist, arrays, java
Solution
You can try using Apache commons CollectionUtils.retainAll method : Returns a collection containing all the elements in collection1 that are also in collection2.
ArrayList commonList = CollectionUtils.retainAll(arrayList1, arrayList2);
If the size of commonList is equal to `arrayList1` and `arrayList2` you can say both the list are same.
Problem
I want to compare these two `ArrayList`: ``` public static ArrayList<List<String>> arrayList1 = new ArrayList<List<String>>(); public static ArrayList<List<String>> arrayList2 = new ArrayList<List<String>>(); ``` If they have the same elements it will return true, otherwise false.