这个有点像spark的reduceByKey,即根据传入的方法一次计算:
@Test public void parallelPrefix(){ Arrays.parallelPrefix(ints,(x,y)->(x+y)); System.out.println(Arrays.deepToString(ints));//[5, 6, 10, 13, 15] } parallelSetAll这个方法相当于stream.map会挨个元素遍历执行方法
@Test public void parallelSetAll(){ Arrays.parallelSetAll(ints,x->x*x); System.out.println(Arrays.toString(ints));//[0, 1, 4, 9, 16] } setAll这个方法与上面类似,只不过不是并行的
@Test public void setAll(){ Arrays.setAll(ints,x->x*2); System.out.println(Arrays.toString(ints)); }