sum() finished

This commit is contained in:
artem.didytschuk 2020-08-31 22:29:57 +02:00
parent 027abe4550
commit b8abf25cf2
1 changed files with 8 additions and 1 deletions

View File

@ -143,7 +143,14 @@ public class Arrays {
* Für ein leeres Array wird 0 zurück gegeben.
*/
public int sum( int[] pArray ) {
return 0;
if( pArray.length == 0 ) {
return 0;
}
int sum = 0;
for( int i = 0; i < pArray.length; i++ ) {
sum += pArray[i];
}
return sum;
}
/**