Does using lambdas in Java, e.g. when invoking collection.removeif(item -> item.isOptionSet())
, has any noticable negative impact on performance or memory usage compared to writing it explicitly
for (Iterator it = collection.iterator(); it.hasNext();) {
if (it.next().isOptionSet()) {
it.remove();
}
}
From a performance/memory point of view, is the above lambda similar to
collection.removeIf(new Predicate<Item>() {
@Override
public boolean test(Item item) {
return item.isOptionSet();
}
});
?