This commit is contained in:
Tim Tersch
2020-08-27 10:59:41 +02:00
parent cb25a9c820
commit 8f735d4b9f

View File

@@ -142,8 +142,15 @@ public class Arrays {
* Für ein leeres Array wird 0 zurück gegeben.
*/
public int sum( int[] pArray ) {
if (pArray == null || pArray.length == 0) {
return 0;
}
int sum = 0;
for (int i : pArray) {
sum += i;
}
return sum;
}
/**
* Berechnet den Mittelwert (average) eines