private static int sumArray ( int [ ] arr ) { if ( arr == null ) throw new NullPointerException ( "null array" ) ; if ( arr . length == 0 ) throw new IllegalArgumentException ( "Zero-length array" ) ; int sum = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] <= 0 ) { throw new IllegalArgumentException ( "All array values must be > 0" ) ; } sum += arr [ i ] ; } return sum ; }
Calculates the sum of the values in the given array .