Java List Compare compareLists(List strings1, List strings2, boolean ignoreCase)

Here you can find the source of compareLists(List strings1, List strings2, boolean ignoreCase)

Description

Determines if the lists of strings contain equal strings

License

Open Source License

Parameter

Parameter Description
strings1 a parameter
strings2 a parameter
ignoreCase a parameter

Declaration

public static boolean compareLists(List strings1, List strings2, boolean ignoreCase) 

Method Source Code

//package com.java2s;
/*// w  ww . j  a  va 2 s . co m
 * JBoss, Home of Professional Open Source.
 *
 * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
 *
 * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
 */

import java.util.List;

public class Main {
    /**
     * Determines if the lists of strings contain equal strings
     * 
     * @param strings1
     * @param strings2
     * @param ignoreCase
     * @return
     * @since 5.0
     */
    public static boolean compareLists(List strings1, List strings2, boolean ignoreCase) {
        int size1 = strings1.size();
        int size2 = strings2.size();
        if (size1 != size2) {
            return false;
        }

        for (int i = 0; i < size1; i++) {
            if (ignoreCase) {
                if (!((String) strings1.get(i)).equals(strings2.get(i))) {
                    return false;
                }
            } else {
                if (!((String) strings1.get(i)).equalsIgnoreCase((String) strings2.get(i))) {
                    return false;
                }
            }
        }
        return true;
    }
}

Related

  1. compareIncarnations(List e1, List e2)
  2. compareList(List listA, List listB)
  3. compareList(Object eObj, Object rObj)
  4. compareLists(Class type, List list1, List list2)
  5. compareLists(final List list1, final List list2)
  6. compareLists(List l1, List l2)
  7. compareLists(List list, List> listOfLists)
  8. compareLists(List a, List b)
  9. compareLists(List a, List b)