Here you can find the source of max(final int[] arr)
Parameter | Description |
---|---|
arr | The array. |
public static int max(final int[] arr)
//package com.java2s; //License from project: Open Source License public class Main { /**// www . j av a 2 s . c o m * Getter. * * @param arr The array. * @return The maximal value of the array. */ public static int max(final int[] arr) { if (arr.length == 0) throw new IllegalArgumentException("must not be empty"); int max = Integer.MIN_VALUE; for (final int v : arr) { if (v > max) { max = v; } } return max; } /** * Getter. * * @param arr The array. * @return The maximal value of the array. */ public static double max(final double[] arr) { if (arr.length == 0) throw new IllegalArgumentException("must not be empty"); double max = Double.NaN; for (final double v : arr) { if (v > max || Double.isNaN(max)) { max = v; } } return max; } }