Java List Compare compareStringLists(List elements1, List elements2)

Here you can find the source of compareStringLists(List elements1, List elements2)

Description

Compare two array lists, if any of the elements in elements1 matches to either one of the element in elements2, return true else return false.

License

Apache License

Parameter

Parameter Description
elements1 a parameter
elements2 a parameter

Declaration

public static boolean compareStringLists(List<String> elements1, List<String> elements2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    /**/*ww  w.j a  va 2s.co  m*/
     * Compare two array lists, if any of the elements in elements1 matches to
     * either one of the element in elements2, return true else return false.
     * 
     * @param elements1
     * @param elements2
     * @return
     */
    public static boolean compareStringLists(List<String> elements1, List<String> elements2) {
        for (String element1 : elements1) {
            for (String element2 : elements2) {
                if (element1.equals(element2)) {
                    return true;
                }
            }
        }
        return false;
    }
}

Related

  1. compareLists(Object obj1, Object obj2)
  2. compareLists(String list1[], String list2[])
  3. compareListsAndNull(List arg1, List arg2)
  4. comparer(Comparator comparator, T object, T... withList)
  5. compareStringList(List list1, List list2)
  6. compareSubstring(List pieces, String s)
  7. compareTermList(final List tl0, final List tl1)
  8. compareTo(List list, int i, int j)
  9. compareTwoListOfStrings(List first, List second)