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