Java Reference
In-Depth Information
Listing 5.1. Find all transactions in 2011 and sort by value (small to
high)
Listing 5.2. What are all the unique cities where the traders work?
You haven't seen this yet, but you could also drop distinct() and use toSet() instead, which
would convert the stream into a set. You'll learn more about it in chapter 6 .
Set<String> cities =
transactions.stream()
.map(transaction -> transaction.getTrader().getCity())
.collect(toSet());
Listing 5.3. Find all traders from Cambridge and sort them by name
Listing 5.4. Return a string of all traders' names sorted alphabetically
 
Search WWH ::




Custom Search