Is there possibility of sum of ArrayList without looping

后端 未结 13 1423
无人共我
无人共我 2020-11-27 04:24

Is there possibility of sum of ArrayList without looping?

PHP provides sum(array) which will give the sum of array.

The PHP code is

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 04:58

    Or switch to Groovy, it has a sum() function on a collection. [1,2,3,4,5,6].sum()

    http://groovy.codehaus.org/JN1015-Collections

    Runs on the same JVM as your java classes.

提交回复
热议问题