Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { public static boolean equals(Collection<?> collection1, Collection<?> collection2) { if (collection1 == collection2) { return true; } if (collection1.size() != collection2.size()) { return false; } final Iterator<?> iterator1 = collection1.iterator(); final Iterator<?> iterator2 = collection2.iterator(); while (iterator1.hasNext()) { final Object object1 = iterator1.next(); final Object object2 = iterator2.next(); if ((object1 == null && object2 != null) || (object1 != null && object2 == null)) { return false; } if (object1 != null && !object1.equals(object2)) { return false; } } return true; } }