You need to sign in to do that
Don't have an account?

compare two lists and remove records which are common in both lists from list1
I have two lists of dates list one contains 100 days dates from tomorrow and list two contains dates which come from api that contains holidays and weekends. I need to compare both the lists and remove second list values from the first list. I have tried to compare and remove but it is not giving proper result.Please help me how to do it in apex.
List<String> list2 = new List<String>{'test1','test3'};
Set<String> set1 = new Set<String>(list1); // Copy the list as a set.
set1.removeAll(list2); // Remove the items from list2.
system.debug(set1); // Set1 contains {'test2','test4'}