Is there possibility of sum of ArrayList without looping

后端 未结 13 1342
无人共我
无人共我 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条回答
  • 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.

    0 讨论(0)
提交回复
热议问题