Here you can find the source of containsSameItems(Collection> col1, Collection> col2)
public static boolean containsSameItems(Collection<?> col1, Collection<?> col2)
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static boolean containsSameItems(Collection<?> col1, Collection<?> col2) { if (col1 == col2) return true; if (col1 == null || col2 == null) return false; if (col1.size() != col2.size()) return false; List<Object> checkList = new ArrayList<Object>(col1); checkList.removeAll(col2);/*from www. j a v a 2s . c o m*/ return checkList.isEmpty(); } }