Java List Equal isEqualList(List list1, List list2)

Here you can find the source of isEqualList(List list1, List list2)

Description

check equal without caring about the order.

License

Open Source License

Declaration

public static <T> boolean isEqualList(List<T> list1, List<T> list2) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    /**// w w w  .j  a v a2s . c o  m
     * check equal without caring about the order.
     */
    public static <T> boolean isEqualList(List<T> list1, List<T> list2) {
        if (list1 == list2) {
            return true;
        }
        if (list1 == null || list2 == null || list1.size() != list2.size()) {
            return false;
        }
        for (T obj1 : list1) {
            if (!list2.contains(obj1)) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. isEqual(Collection listA, Collection listB)
  2. isEqual(List list1, List list2)
  3. isEqual(List from, List to)
  4. isEqualAsMultiset(List left, List right)
  5. isEqualIgnoringOrder(List left, List right)
  6. isEquals(List l1, List l2)
  7. isEquals(List l1, List l2)