Java Set Union union(final Set set1, final Set set2)

Here you can find the source of union(final Set set1, final Set set2)

Description

union

License

Apache License

Declaration

public static <E> Set<E> union(final Set<E> set1, final Set<E> set2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static <E> Set<E> union(final Set<E> set1, final Set<E> set2) {
        Set<E> set = new HashSet<>(set1);
        set.addAll(set2);//from w  w  w. j a  v a 2 s. com
        return Collections.unmodifiableSet(set);
    }
}

Related

  1. union(final Iterable> elements)
  2. union(final Set... elements)
  3. union(Set one, Set two)
  4. union(Set a, Set b)
  5. union(Set left, Set right)