Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

public class Main {
    /**
     * Inserts into one collection all elements of another collection not
     * contained in that collection.
     * <p>
     * Uses {@code Collection#contains(java.lang.Object)} to compare elements.
     *
     * @param <T>    the collection's element type
     * @param src    source collection to get elements from
     * @param target target collection to put elements into
     */
    public static <T> void addNotContainedElements(Collection<? extends T> src, Collection<? super T> target) {
        if (src == target) {
            return;
        }

        for (T t : src) {
            if (!target.contains(t)) {
                target.add(t);
            }
        }
    }
}