Given 2 lists List<Group> old, List<Group> new Write the for loop so that it iterates through the union of two lists and finds the count of groups which are not present in both. Compare the groupNames by ignoring the case and using one for loop.
class Group { private String name; private int members; private int revenue; private int overhead; private boolean newGroup; public Group(String name, int members, int revenue, int overhead, boolean newGroup) { this.name = name; this.members = members; this.revenue = revenue; this.overhead = overhead; this.newGroup = newGroup; } } public static int getCountOfGroupsNotInBoth(List<Group> old, List<Group> new) { int count = 0; Set<String> oldGroups = new HashSet<>(); for (Group g : old) { oldGroups.add(g.getName().toLowerCase()); } for (Group g : newGroups) { if (!oldGroups.contains(g.getName().toLowerCase())) { count++; } } return count; }