diff --git a/jdk/src/java.base/share/classes/java/util/Arrays.java b/jdk/src/java.base/share/classes/java/util/Arrays.java index a7d9dccd7a5..ae321498dc4 100644 --- a/jdk/src/java.base/share/classes/java/util/Arrays.java +++ b/jdk/src/java.base/share/classes/java/util/Arrays.java @@ -4685,6 +4685,14 @@ public class Arrays { *
If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .forEach(i -> array[i] = generator.apply(i)); + * }+ * * @param
{@code + * IntStream.range(startInclusive, endExclusive) + * .parallel() + * .forEach(i -> array[i] = generator.apply(i)); + * }+ * * @param
If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .forEach(i -> array[i] = generator.applyAsInt(i)); + * }+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4745,6 +4770,15 @@ public class Arrays { * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .parallel() + * .forEach(i -> array[i] = generator.applyAsInt(i)); + * }+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4763,6 +4797,14 @@ public class Arrays { *
If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .forEach(i -> array[i] = generator.applyAsLong(i)); + * }+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4783,6 +4825,15 @@ public class Arrays { * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .parallel() + * .forEach(i -> array[i] = generator.applyAsLong(i)); + * }+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4801,6 +4852,14 @@ public class Arrays { *
If the generator function throws an exception, it is relayed to * the caller and the array is left in an indeterminate state. * + * @apiNote + * Setting a subrange of an array, using a generator function to compute + * each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .forEach(i -> array[i] = generator.applyAsDouble(i)); + * }+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position @@ -4821,6 +4880,15 @@ public class Arrays { * is thrown from {@code parallelSetAll} and the array is left in an * indeterminate state. * + * @apiNote + * Setting a subrange of an array, in parallel, using a generator function + * to compute each element, can be written as follows: + *
{@code + * IntStream.range(startInclusive, endExclusive) + * .parallel() + * .forEach(i -> array[i] = generator.applyAsDouble(i)); + * }+ * * @param array array to be initialized * @param generator a function accepting an index and producing the desired * value for that position