get Different Element between two String list - Java java.util

Java examples for java.util:List Compare

Description

get Different Element between two String list

Demo Code

/*/*from www . j av a  2s . co m*/
 * @(#)2013-10-12 V1.0
 * 
 * Copyright 2013 WELL-SOFT, Inc. All rights reserved.
 */
//package com.java2s;
import java.util.*;

public class Main {
    public static void main(String[] argv) {
        List minList = java.util.Arrays.asList("asdf", "java2s.com");
        List maxList = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(getDifferentElement(minList, maxList));
    }

    public static List<String> getDifferentElement(List<String> minList,
            List<String> maxList) {
        List<String> newList = new ArrayList<String>();
        for (String max : maxList) {
            if (!(minList.contains(max))) {
                newList.add(max);
            }
        }
        return newList;
    }
}

Related Tutorials