Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static List<String>[] diff(List<String> list1, List<String> list2) {
        if (list1 == null)
            list1 = new ArrayList<String>();
        if (list2 == null)
            list2 = new ArrayList<String>();

        List<String> toAddList = new ArrayList<String>();
        List<String> toDelList = new ArrayList<String>();

        for (String str1 : list1) {
            if (!list2.contains(str1)) {
                toAddList.add(str1);
            }
        }

        for (String str2 : list2) {
            if (!list1.contains(str2)) {
                toDelList.add(str2);
            }
        }

        return new List[] { toAddList, toDelList };
    }
}