Here you can find the source of max(double[] values)
Parameter | Description |
---|---|
values | double array the maximum is calculated from |
public static double max(double[] values)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww.j a v a 2s .c om * Calculates the maximum over an given array of doubles. * * @param values * double array the maximum is calculated from * @return maximum value of the given double array */ public static double max(double[] values) { try { double max = values[0]; for (double v : values) { if (v > max) max = v; } return max; } catch (ArrayIndexOutOfBoundsException e) { return 0; } } /** * Calculates the maximum over an given array of integers. * * @param values * integer array the maximum is calculated from * @return maximum value of the given integer array */ public static int max(int[] values) { try { int max = values[0]; for (int v : values) { if (v > max) max = v; } return max; } catch (ArrayIndexOutOfBoundsException e) { return 0; } } /** * Calculates the maximum over an given array of longs. * * @param values * long array the maximum is calculated from * @return maximum value of the given long array */ public static long max(long[] values) { try { long max = values[0]; for (long v : values) { if (v > max) max = v; } return max; } catch (ArrayIndexOutOfBoundsException e) { return 0; } } }