Here you can find the source of isEqual(Collection
public static <T> boolean isEqual(Collection<T> listA, Collection<T> listB)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2007 Boeing./*from www . ja va2s .co m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Boeing - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { /** * Return true if same objects exist in listA and listB */ public static <T> boolean isEqual(Collection<T> listA, Collection<T> listB) { if (listA.size() != listB.size()) { return false; } if (listA.size() != setIntersection(listA, listB).size()) { return false; } return true; } /** * @return The intersection of two sets A and B is the set of elements common to A and B */ public static <T> List<T> setIntersection(Collection<T> listA, Collection<T> listB) { ArrayList<T> intersection = new ArrayList<T>(listA.size()); for (T obj : listA) { if (listB.contains(obj)) { intersection.add(obj); } } return intersection; } }