compare two List for equal - Java java.util

Java examples for java.util:List Compare

Description

compare two List for equal

Demo Code


//package com.java2s;
import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List a = java.util.Arrays.asList("asdf", "java2s.com");
        List set2 = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(compare(a, set2));
    }/*from  w  w w  .  j av  a  2  s  . c  o  m*/

    public static boolean compare(List<Integer> a, List<Integer> set2) {
        if (a.size() != set2.size()) {
            return false;
        }

        return a.containsAll(set2);
    }
}

Related Tutorials