equals Lists - Java Collection Framework

Java examples for Collection Framework:List

Description

equals Lists

Demo Code


//package com.java2s;

import java.util.List;

public class Main {
    public static <T> boolean equalsLists(List list1, List list2) {
        if (list1.size() != list2.size()) {
            return false;
        }/*  www  . j  a  v  a2  s .  c om*/

        for (int i = 0; i < list1.size(); ++i) {
            if (!equals(list1.get(i), list2.get(i))) {
                return false;
            }
        }

        return true;
    }

    public static boolean equals(Object a, Object b) {
        if (a == null) {
            return b == null;
        }

        return a.equals(b);
    }
}

Related Tutorials