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
checkOrders
method ofShippingHelper
. UseList
'sremoveIf
method to check if orders contain only one item. Pass an inline lambda expression toremoveIf
that implements thePredicate
functional interface. The methodremoveIf
will remove the item from theList
if the condition evaluates totrue
. Therefore, the lambda expression should returntrue
if the order has more than one item.
HINTS: