Looked several answers on stack, tried to do it with help of this one Simple way to compare 2 ArrayLists but can't try to figure out what seems to be a problem. To summarize the code that isnt visible, I've created two arraylists that contain 4 files names. Now im trying to get the third arraylist which will contain only unique values from these two arraylists. Example: 1st arraylist - One, Two, Three, Four 2nd arraylist - One, Three, Five, Seven 3rd arraylist - Two, Four, Five, Seven (solution arraylist) Here is the code:
Collection<String> filesFromDir = new
ArrayList(Arrays.asList(listOfFilenamesWithNoExtension));
Collection<String> filesFromDB = new ArrayList(Arrays.asList(listOfFilesDB));
List<String> listDir = new ArrayList<String>(filesFromDir);
List<String> listDB = new ArrayList<String>(filesFromDB);
listDir.removeAll(listDB);
listDB.removeAll(listDir);
System.out.println("Unique values: ");
System.out.println(listDir);
System.out.println(listDB);