Here you can find the source of contentEquals(Collection
public static <T> boolean contentEquals(Collection<T> list1, Collection<T> list2)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static <T> boolean contentEquals(Collection<T> list1, Collection<T> list2) { if (list1 == list2) { return true; }/* www. ja va2 s . c o m*/ if (list1 == null || list2 == null) { return false; } if (list1.size() != list2.size()) { return false; } for (T item : list1) { if (!list2.contains(item)) return false; } return true; } }