public static double max(double[] arr) { double result = Double.NEGATIVE_INFINITY; for (int i = 0; i < arr.length; ++i) { if (result < arr[i]) result = arr[i]; } return result; }