@@ -0,0 +1,785 @@
+package com.insightfullogic.java8.answers.chapter5;%0D%0A%0D%0Aimport java.util.Comparator;%0D%0Aimport java.util.List;%0D%0Aimport java.util.stream.Collectors;%0D%0A%0D%0Aimport com.insightfullogic.java8.examples.chapter1.Artist;%0D%0A%0D%0Aimport static java.util.Comparator.comparing;%0D%0A%0D%0Apublic class LongestName %7B%0D%0A%0D%0A%09private static Comparator%3CArtist%3E byNameLength = comparing(artist -%3E artist.getName().length());%0D%0A%0D%0A%09public static Artist byReduce(List%3CArtist%3E artists) %7B%0D%0A%09%09return artists.stream().reduce((acc, artist) -%3E %7B%0D%0A%09%09%09return (byNameLength.compare(acc, artist) %3E= 0) ? acc : artist;%0D%0A%09%09%7D).orElseThrow(RuntimeException::new);%0D%0A%09%7D%0D%0A%0D%0A%09public static Artist byCollecting(List%3CArtist%3E artists) %7B%0D%0A%09%09return artists.stream().collect(Collectors.maxBy(byNameLength)).orElseThrow(RuntimeException::new);%0D%0A%09%7D%0D%0A%7D%0D%0A

add LongestName solution by reduce and collect for chapter5