Expected time required: 15 min
In this scenario, you are processing a list of orders to determine which orders contain only one item so that item
picking and packaging can be done without human intervention. You have a list of orders, each order is a list of items.
You must remove any orders that contain more than one item. List contains a method removeIf that accepts a
Predicate interface as an argument. Implement the checkOrders method of ShippingHelper using a lambda expression
for the input argument for removeIf.
- Implement the
checkOrdersmethod ofShippingHelper. UseList'sremoveIfmethod to check if orders contain only one item. Pass an inline lambda expression toremoveIfthat implements thePredicatefunctional interface. The methodremoveIfwill remove the item from theListif the condition evaluates totrue. Therefore, the lambda expression should returntrueif the order has more than one item.
HINTS: