#java methods
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
public void listShipmentsForClient(Client client) {
System.out.println("\nShipments for Client ID: " + client.getId());
shipments.stream()
.filter(s -> s.getShipper().equals(client))
.forEach(System.out::println);
}
In which sense?
taking out stream
You could do a for each, with an if, and add it to a second list, but that seems more cumbersome.
ohhh
yeah it cant get much "simpler" in terms of amount of code but it is probably more efficient to java for (var shipment : shipments) { if (shipment.getShipper().equals(client)) { System.out.println(shipment); } }
Detected code, here are some useful tools:
I prefer a stream to be honest, it's a more logical sequence of actions.