private double [ ] max ( double [ ] distances1 , double [ ] distances2 ) { if ( distances1 . length != distances2 . length ) { throw new RuntimeException ( "different lengths!" ) ; } double [ ] result = new double [ distances1 . length ] ; for ( int i = 0 ; i < distances1 . length ; i ++ ) { result [ i ] = Math . max ( distances1 [ i ] , distances2 [ i ] ) ; } return result ; }
Returns an array that holds the maximum values of the both specified arrays in each index .