@@ -0,0 +1,1832 @@
+package java8_in_action.chapter5;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors;%0A%0Apublic class Exercise5_5_1 %7B%0A    public static void main(String... args) %7B%0A        System.out.println(%22exercise 5.5.1 starting...%22);%0A%0A        // domain for this exercise%0A        Trader raoul = new Trader(%22Raoul%22, %22Cambridge%22);%0A        Trader mario = new Trader(%22Mario%22, %22Milan%22);%0A        Trader alan = new Trader(%22Alan%22, %22Cambridge%22);%0A        Trader brian = new Trader(%22Brian%22, %22Cambridge%22);%0A        List%3CTransaction%3E transactions = Arrays.asList(%0A                new Transaction(brian, 2011, 300),%0A                new Transaction(raoul, 2012, 1000),%0A                new Transaction(raoul, 2011, 400),%0A                new Transaction(mario, 2012, 710),%0A                new Transaction(mario, 2012, 700),%0A                new Transaction(alan, 2012, 950));%0A%0A        //1.%C2%A0%C2%A0Find all transactions in the year 2011 and sort them by value (small to high).%0A        List%3CTransaction%3E txn2011ByValue = transactions.stream()%0A                .filter(t -%3E t.getYear() == 2011)%0A                .sorted(Comparator.comparing(Transaction::getValue))%0A                .collect(Collectors.toList());%0A%0A        System.out.println(%222011 txns by value, list=%22 + txn2011ByValue);%0A%0A        //2.%C2%A0%C2%A0What are all the unique cities where the traders work?%0A        //3.%C2%A0%C2%A0Find all traders from Cambridge and sort them by name.%0A        //4.%C2%A0%C2%A0Return a string of all traders%E2%80%99 names sorted alphabetically.%0A        //5.%C2%A0%C2%A0Are any traders based in Milan?%0A        //6.%C2%A0%C2%A0Print all transactions%E2%80%99 values from the traders living in Cambridge.%0A        //7.%C2%A0%C2%A0What%E2%80%99s the highest value of all the transactions?%0A        //8.%C2%A0%C2%A0Find the transaction with the smallest value.%0A%0A        System.out.println(%22exercise 5.5.1 done.%22);%0A    %7D%0A%7D%0A

question 1 done