I have 2 arraylists of string object.
List sourceList = new ArrayList();
List destinationList = new ArrayList
Convert Lists to Collection and use removeAll
Collection listOne = new ArrayList(Arrays.asList("a","b", "c", "d", "e", "f", "g"));
Collection listTwo = new ArrayList(Arrays.asList("a","b", "d", "e", "f", "gg", "h"));
List sourceList = new ArrayList(listOne);
List destinationList = new ArrayList(listTwo);
sourceList.removeAll( listTwo );
destinationList.removeAll( listOne );
System.out.println( sourceList );
System.out.println( destinationList );
Output:
[c, g]
[gg, h]
[EDIT]
other way (more clear)
Collection list = new ArrayList(Arrays.asList("a","b", "c", "d", "e", "f", "g"));
List sourceList = new ArrayList(list);
List destinationList = new ArrayList(list);
list.add("boo");
list.remove("b");
sourceList.removeAll( list );
list.removeAll( destinationList );
System.out.println( sourceList );
System.out.println( list );
Output:
[b]
[boo]