Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<Integer> first = Arrays.asList(2, 3, 4, 5);
        List<Integer> second = Arrays.asList(1, 3, 4, 6);

        List<Integer> missing = new LinkedList<Integer>();
        List<Integer> added = new LinkedList<Integer>(second);

        for (Integer i : first) {
            if (!added.remove(i)) {
                missing.add(i);
            }
        }

        System.out.println("Missing ints in second: " + missing);
        System.out.println("New ints in second: " + added);
    }
}