question: public static int eliminateZeroMassPoints ( int [ ] densityPoints , double [ ] densityValues ) { int positiveMassCount = 0 ; for ( int i = 0 ; i < densityValues . length ; i ++ ) { if ( densityValues [ i ] > 0 ) { positiveMassCount ++ ; } } if ( positiveMassCount < densityValues . length ) { int [ ] newPoints = new int [ positiveMassCount ] ; double [ ] newValues = new double [ positiveMassCount ] ; int j = 0 ; for ( int i = 0 ; i < densityValues . length ; i ++ ) { if ( densityValues [ i ] > 0 ) { newPoints [ j ] = densityPoints [ i ] ; newValues [ j ] = densityValues [ i ] ; j ++ ; } } System . arraycopy ( newPoints , 0 , densityPoints , 0 , positiveMassCount ) ; System . arraycopy ( newValues , 0 , densityValues , 0 , positiveMassCount ) ; } return positiveMassCount ; }
target:  Eliminates points with zero mass from densityPoints and densityValues parallel arrays.  Returns the number of positive mass points and collapses the arrays so that the first <returned value> elements of the input arrays represent the positive mass points.