I would like to know how can I get all the elements from a collection containing a specific value.
Like this:
@Override
public Collection<Sale> selectSales(String map) {
HashSet<Sale> sales = new HashSet();
for (Sale sale : salesList) {
if (sale.getMap().equals(map)) {
sales.add(sale);
}
}
return sales;
}
But I would like to filter the collection directly. I read that I can do this using LAMBDA, example:
list.removeIf(c -> c.getCarColor() == Color.BLUE);
But I Don't know how to apply this example.
Thank you.