Set<Badge> availableBadges = myService.getAvailableBadges();
List<Badge> allBadges = Arrays.asList(Badge.values());
allBadges.removeAll(availableBadges);
/* Badge is an enumn */
what collections do support remove all ?
Set<Badge> availableBadges = myService.getAvailableBadges();
List<Badge> allBadges = Arrays.asList(Badge.values());
allBadges.removeAll(availableBadges);
/* Badge is an enumn */
what collections do support remove all ?
Arrays.asList
returns a partially unmodifiable implementation (in part of remove*
methods - thanks to @LouisWasserman for the remark) of the List
interface.
EDIT 1: Use an ArrayList
wrapper on it: new ArrayList<Badge>(allBadges);
Your collection might be unmodifiable.
You need to create new List
List<T> list = new ArrayList<>(unmodifiableList);
Now your list is modifiable and you can perform remove and removeAll
operations.