jdk/src/share/classes/java/util/stream/package-info.java
changeset 25224 7c7e029826e1
parent 22291 6106c1f013f1
equal deleted inserted replaced
25223:4d33af5975a5 25224:7c7e029826e1
   466  * re-cast the simple sum-of-weights example using the more general form as
   466  * re-cast the simple sum-of-weights example using the more general form as
   467  * follows:
   467  * follows:
   468  * <pre>{@code
   468  * <pre>{@code
   469  *     int sumOfWeights = widgets.stream()
   469  *     int sumOfWeights = widgets.stream()
   470  *                               .reduce(0,
   470  *                               .reduce(0,
   471  *                                       (sum, b) -> sum + b.getWeight())
   471  *                                       (sum, b) -> sum + b.getWeight(),
   472  *                                       Integer::sum);
   472  *                                       Integer::sum);
   473  * }</pre>
   473  * }</pre>
   474  * though the explicit map-reduce form is more readable and therefore should
   474  * though the explicit map-reduce form is more readable and therefore should
   475  * usually be preferred. The generalized form is provided for cases where
   475  * usually be preferred. The generalized form is provided for cases where
   476  * significant work can be optimized away by combining mapping and reducing
   476  * significant work can be optimized away by combining mapping and reducing