diff --git a/Java Streams/src/StreamProducts.java b/Java Streams/src/StreamProducts.java index 6bed3c7..038719a 100644 --- a/Java Streams/src/StreamProducts.java +++ b/Java Streams/src/StreamProducts.java @@ -11,16 +11,19 @@ public class StreamProducts { List streamProducts = new ArrayList<>(); streamProducts.add(door); - streamProducts.add(floorPanel); streamProducts.add(window); streamProducts.add(floorPanel); - streamProducts.add(window); namesOfLightProductsWeightSortedLoop(streamProducts); namesOfLightProductsWeightSortedLoopStreamed(streamProducts); } private static void namesOfLightProductsWeightSortedLoopStreamed(List streamProducts) { + streamProducts.stream() + .filter(streamProduct -> streamProduct.getWeight() < 30) + .sorted(comparingInt(StreamProduct::getWeight)) + .map(StreamProduct::getName) + .forEach(System.out::println); }