diff --git a/src/main/java/lambdasinaction/chap5/PuttingIntoPractice.java b/src/main/java/lambdasinaction/chap5/PuttingIntoPractice.java index d0b13ae5..6df02bde 100644 --- a/src/main/java/lambdasinaction/chap5/PuttingIntoPractice.java +++ b/src/main/java/lambdasinaction/chap5/PuttingIntoPractice.java @@ -84,7 +84,13 @@ public static void main(String ...args){ int highestValue = transactions.stream() .map(Transaction::getValue) - .reduce(0, Integer::max); + .reduce(Integer.MIN_VALUE, Integer::max); System.out.println(highestValue); + + //Query 8: Find the transaction with the smallest value. + int smallestValue = transactions.stream() + .map(Transaction::getValue) + .reduce(Integer.MAX_VALUE, Integer::min); + System.out.println(smallestValue); } -} \ No newline at end of file +}