check Match between two List item - Java java.util

Java examples for java.util:List Compare

Description

check Match between two List item

Demo Code


//package com.java2s;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List proposalList = java.util.Arrays.asList("asdf", "java2s.com");
        List expectedList = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(checkMatch(proposalList, expectedList));
    }//from   w  ww.j a v a  2 s .  co  m

    public static boolean checkMatch(List<String> proposalList,
            List<String> expectedList) {
        boolean match = false;
        for (String expectedValue : expectedList) {
            match = false;
            for (String proposeValue : proposalList) {
                if (expectedValue.equals(proposeValue)) {
                    match = true;
                }
            }
            if (!match)
                return match;
        }
        return match;
    }
}

Related Tutorials