Java Reference
In-Depth Information
Listing 6.5. The ToListCollector
Note that this implementation isn't identical to the one returned by the Collectors .toList
method, but it differs only in some minor optimizations. These optimizations are mostly related
to the fact that the collector provided by the Java API uses the Collections.emptyList() singleton
when it has to return an empty list. This means that it could be safely used in place of the
original Java as an example to gather a list of all the Dishes of a menu stream:
List<Dish> dishes = menuStream.collect(new ToListCollector<Dish>());
The remaining difference from this and the standard
 
Search WWH ::




Custom Search