Skip to content

Commit

Permalink
Add methods sum(int...) & sum(long...)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmjsjx committed Jan 25, 2021
1 parent bca804d commit 3990cfd
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,34 @@ public static final boolean notInRangeExclude(int value, int begin, int end) {
return value <= begin || value >= end;
}

/**
* Returns the sum of the given values.
*
* @param values the values
* @return the sum of the given values
*/
public static final int sum(int... values) {
var sum = 0;
for (int v : values) {
sum += v;
}
return sum;
}

/**
* Returns the sum of the given values.
*
* @param values the values
* @return the sum of the given values
*/
public static final long sum(long... values) {
var sum = 0L;
for (long v : values) {
sum += v;
}
return sum;
}

private NumberUtil() {
}

Expand Down

0 comments on commit 3990cfd

Please sign in to comment.