I need to get the list of uncommon element while comparing two lists .
ex:-
List<String> readAllName = {"aaa","bbb","ccc","ddd"};
List<String> selectedName = {"bbb","ccc"};
here i want uncommon elements from readAllName list (“aaa”,”ccc”,”ddd”) in another list.
Without Using remove()and removeAll().
Assuming the expected output is
aaa, ccc, eee, fff, xxx(all the not-common items), you can useList#removeAll, but you need to use it twice to get both the items in name but not in name2 AND the items in name2 and not in name:As per your edit, you can’t use
removeorremoveAll– in that case you can simply run two loops: