Here you can find the source of maxValue(float[] arr)
Parameter | Description |
---|---|
arr | array of floats |
public static float maxValue(float[] arr)
//package com.java2s; public class Main { /**/*from ww w . j a v a2 s . c o m*/ * Returns the largest value in the array * * @param arr array of floats * @return the value */ public static float maxValue(float[] arr) { if (arr.length < 0) return 0; float max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; } /** * Returns the largest value in the array * * @param arr array of double * @return the value */ public static double maxValue(double[] arr) { if (arr.length < 0) return 0; double max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; } /** * Returns the largest value in the array * * @param arr array of bytes * @return the value */ public static byte maxValue(byte[] arr) { if (arr.length < 0) return 0; byte max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; } /** * Returns the largest value in the array * * @param arr array of shorts * @return the value */ public static short maxValue(short[] arr) { if (arr.length < 0) return 0; short max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; } /** * Returns the largest value in the array * * @param arr array of ints * @return the value */ public static int maxValue(int[] arr) { if (arr.length < 0) return 0; int max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; } /** * Returns the largest value in the array * * @param arr array of longs * @return the value */ public static long maxValue(long[] arr) { if (arr.length < 0) return 0; long max = arr[0]; for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max; } }