Java Utililty Methods ArrayList Union

List of utility methods to do ArrayList Union

Description

The list of methods to do ArrayList Union are organized into topic(s).

Method

ArrayListunion(ArrayList list1, ArrayList list2)
union
ArrayList<String> result = new ArrayList<String>();
result.addAll(list1);
result.addAll(list2);
Collections.sort(result);
return distinct(result);
ArrayListUnion(ArrayList list1, ArrayList list2)
Finds the union of two lists of String objects
Set union = new HashSet(list1);
union.addAll(new HashSet(list2));
return new ArrayList(union);
ArrayListunion(ArrayList a, ArrayList b)
union
ArrayList<T> result = new ArrayList<T>();
for (T t : a)
    if (!result.contains(t))
        result.add(t);
for (T t : b)
    if (!result.contains(t))
        result.add(t);
return result;
...
ArrayListunionSets(ArrayList s1, ArrayList s2)
union two sets s1 and s2
if (s2 == null) {
    return s1;
for (Integer i : s2) {
    if (!s1.contains(i)) {
        s1.add(i);
return s1;