public List<String> removeRepeatFactor(List<String> list1 , List<String> list2)throws Exception{ if(list1 != null && list2 != null) { if (list1.size() != 0 && list2.size() != 0) { Collection A = new ArrayList(list1); Collection B = new ArrayList(list2); A.retainAll(B); if (A.size() != 0) { B.removeAll(A); } return (List<String>) B; } } return list2; }