< prev index next >

src/java.base/share/classes/java/util/stream/package-info.java

Print this page

        

*** 413,423 **** * over a mutative accumulation such as the above. Not only is a reduction * "more abstract" -- it operates on the stream as a whole rather than individual * elements -- but a properly constructed reduce operation is inherently * parallelizable, so long as the function(s) used to process the elements * are <a href="package-summary.html#Associativity">associative</a> and ! * <a href="package-summary.html#NonInterfering">stateless</a>. * For example, given a stream of numbers for which we want to find the sum, we * can write: * <pre>{@code * int sum = numbers.stream().reduce(0, (x,y) -> x+y); * }</pre> --- 413,423 ---- * over a mutative accumulation such as the above. Not only is a reduction * "more abstract" -- it operates on the stream as a whole rather than individual * elements -- but a properly constructed reduce operation is inherently * parallelizable, so long as the function(s) used to process the elements * are <a href="package-summary.html#Associativity">associative</a> and ! * <a href="package-summary.html#Statelessness">stateless</a>. * For example, given a stream of numbers for which we want to find the sum, we * can write: * <pre>{@code * int sum = numbers.stream().reduce(0, (x,y) -> x+y); * }</pre>
< prev index next >