Here you can find the source of equals(final Collection
public static <T> boolean equals(final Collection<T> c1, final Collection<T> c2)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**/*www . jav a 2s . co m*/ * true if for each a in c1, a exists in c2, * and if for each b in c2, b exist in c1 * and c1 and c2 are the same size. * Note that (a,a,b) (a,b,b) are equal. */ public static <T> boolean equals(final Collection<T> c1, final Collection<T> c2) { if (c1 == null || c2 == null) { return c1 == c2; } if (c1.size() != c2.size()) { return false; } if (c1 == c2) { return true; } if (!c1.containsAll(c2)) { return false; } return c2.containsAll(c1); } }