Java List Add Unique addUniqueItems(List from, List to)

Here you can find the source of addUniqueItems(List from, List to)

Description

add Unique Items

License

Open Source License

Declaration

private static void addUniqueItems(List from, List to) 

Method Source Code

//package com.java2s;
// are made available under the terms of the Eclipse Public License v1.0

import java.util.Iterator;
import java.util.List;

public class Main {
    private static void addUniqueItems(List from, List to) {
        if (from == null || to == null || from.size() == 0) {
            return;
        }//from ww w. j  av  a  2  s.  c o m

        for (Iterator it = from.iterator(); it.hasNext();) {
            Object o = it.next();
            if (!to.contains(o)) {
                to.add(o);
            }
        }
    }
}

Related

  1. addUnique(java.util.List l, String e)
  2. addUnique(List aList, T anObj)
  3. addUnique(List list, T item)
  4. addUnique(List list, T item)
  5. addUniqueId(List aList, T anObj)
  6. addUniqueValues(List source, List target)