Is there possibility of sum of ArrayList without looping

后端 未结 13 1430
无人共我
无人共我 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:52

    You can use GNU Trove library:

    TIntList tt = new TIntArrayList();
    tt.add(1);
    tt.add(2);
    tt.add(3);
    int sum = tt.sum();
    

提交回复
热议问题