Java List Union union(final List list1, final List list2)

Here you can find the source of union(final List list1, final List list2)

Description

union

License

Open Source License

Declaration

public static <E> List<E> union(final List<E> list1, final List<E> list2) 

Method Source Code

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

import java.util.*;

public class Main {
    public static <E> List<E> union(final List<E> list1, final List<E> list2) {
        if (list1 == null || list2 == null)
            throw new NullPointerException("Not initizalized lists");
        List<E> concat = new ArrayList<E>(list1.size() + list2.size());
        concat.addAll(list1);/*from  w ww  .ja v  a  2 s .com*/
        E item;
        ListIterator<E> iter = list1.listIterator();
        while (iter.hasNext()) {
            item = iter.next();
            if (!concat.contains(item)) {
                concat.add(item);
            }
        }
        return concat;
    }
}

Related

  1. shallowUnionCol(Collection> values)
  2. union(final char[]... list)
  3. union(final List list1, final List list2)
  4. union(final List list1, final List list2)
  5. union(final List list1, final List list2)
  6. union(final List... lists)
  7. Union(List A, List B)
  8. union(List ls, List ls2)
  9. union(List byteList)