Either:
Set<Foo> fooSet = new LinkedHashSet<>(one);
fooSet.addAll(two);
List<Foo> finalFoo = new ArrayList<>(fooSet);
or
List<Foo> twoCopy = new ArrayList<>(two);
twoCopy.removeAll(one);
one.addAll(twoCopy);
More Related Contents:
- Unexpected output when creating a List of Lists in Java
- NumberFormatException not wrking java
- Write a program that takes an array/arraylist of integer and finds longest sub array/arraylist whose entries are equal [closed]
- How to create a Java ArrayList in C
- Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 6, Size: 6 [duplicate]
- Convert list to array in Java [duplicate]
- Java List.add() UnsupportedOperationException
- How to randomize two ArrayLists in the same fashion?
- What are the differences between ArrayList and Vector?
- How much data can a List can hold at the maximum?
- Moving items around in an ArrayList
- Efficient way to divide a list into lists of n size
- Trouble with Gson serializing an ArrayList of POJO’s
- what is the sense of final ArrayList?
- Finding duplicate values in arraylist
- Check if an ArrayList contains every element from another ArrayList (or Collection)
- Simple way to compare 2 ArrayLists
- Add object to ArrayList at specified index
- Trying to find all occurrences of an object in Arraylist, in java
- ArrayList Vs LinkedList
- Why can’t you have a “List” in Java? [duplicate]
- Time Complexity for Java ArrayList
- Java Generic with ArrayList
- How to remove specific object from ArrayList in Java?
- Two ArrayList one RecyclerView Adapter
- how to fix java.lang.IndexOutOfBoundsException
- How to declare an ArrayList with values? [duplicate]
- How to change value of ArrayList element in java
- Why do I need to synchronize a list returned by Collections.synchronizedList
- Add ArrayList to another ArrayList in java