One List contains another List All And Only - Android java.util

Android examples for java.util:List Contain

Description

One List contains another List All And Only

Demo Code


//package com.book2s;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List c1 = java.util.Arrays.asList("asdf", "book2s.com");
        List c2 = java.util.Arrays.asList("asdf", "book2s.com");
        System.out.println(containsAllAndOnly(c1, c2));
    }//from   www. ja  va 2s .com

    public static boolean containsAllAndOnly(List<?> c1, List<?> c2) {
        if (c1 == null || c2 == null)
            return false;
        if (c1.size() != c2.size())
            return false;
        if (!c1.containsAll(c2))
            return false;
        return true;
    }
}

Related Tutorials