import java.util.Arrays;
import java.util.List;

public class ListLambada {

    public static void main(String[] args) {
        
        List<Integer> values = Arrays.asList(10,20,30);
        int result = ListLambada.add(values);
        System.out.println("计算结果:" + result);
    }
    
    public static int add(List<Integer> values) {
        
        // 输出遍历的数据.
        // values.parallelStream().forEach(System.out :: println);
        
        // 按顺序计算
        // values.stream().mapToInt(value -> value).sum();
        
        // 获取数据时,无顺序。
        return values.parallelStream().mapToInt(value -> value).sum();
    }
}

 

相关文章:

  • 2021-12-15
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2021-08-22
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
相关资源
相似解决方案