Here you can find the source of maxValue(final int[] arr)
Parameter | Description |
---|---|
arr | array of #t# |
public static int maxValue(final int[] arr)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w. j ava 2 s . c om * Returns the largest value in the array. * * @param arr * array of #t# * @return the value */ public static int maxValue(final 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 #t# * @return the value */ public static float maxValue(final 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; } }