Java List Difference diffList(List aList, List bList)

Here you can find the source of diffList(List aList, List bList)

Description

Returns a list of String objects that appear aList but don't appear in bList.

License

Mozilla Public License

Parameter

Parameter Description
aList a parameter
bList a parameter

Return

objects in aList but not in bList

Declaration

public static List<String> diffList(List<String> aList,
        List<String> bList) 

Method Source Code

//package com.java2s;
/*/*from   ww w.j a  va2  s  .  c o  m*/
 * gnizr is a trademark of Image Matters LLC in the United States.
 * 
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License
 * for the specific language governing rights and limitations under the License.
 * 
 * The Initial Contributor of the Original Code is Image Matters LLC.
 * Portions created by the Initial Contributor are Copyright (C) 2007
 * Image Matters LLC. All Rights Reserved.
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Returns a list of String objects that appear aList but don't appear
     * in bList.
     * @param aList
     * @param bList
     * @return objects in aList but not in bList
     */
    public static List<String> diffList(List<String> aList,
            List<String> bList) {
        List<String> result = new ArrayList<String>();
        for (String a : aList) {
            if (bList.contains(a) == false) {
                result.add(a);
            }
        }
        return result;
    }
}

Related

  1. difference(List lst1, List lst2)
  2. difference(List set1, List set2)
  3. differenceOfList(List a, List b)
  4. differentCategory(String prop1, String prop2, List cat1, List cat2)
  5. diffFloats(List a, List b)
  6. diffSet(List a, List b)
  7. diffSimple(String name, Object expected, Object actual, List messages)
  8. extractDifference(List l1, List l2, List in1not2, List in2not1, List inBothFrom1, List inBothFrom2, Comparator c)
  9. formatDifferentFileNames(List results)