Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

import java.util.HashSet;

import java.util.Set;

public class Main {

    public static <T> Set<T> union(Collection<T> set1, Collection<T> set2) {
        HashSet<T> set = new HashSet<T>();

        for (T object : set1) {
            set.add(object);
        }
        for (T object : set2) {
            if (!set.contains(object)) {
                set.add(object);
            }
        }

        return set;
    }
}