Java Array Min Value minAndMaxOfArray(float[] array)

Here you can find the source of minAndMaxOfArray(float[] array)

Description

Returns the minimal and the maximal value in a given array

License

Open Source License

Parameter

Parameter Description
array the array

Return

an array with minimal and maximal value

Declaration

public static float[] minAndMaxOfArray(float[] array) 

Method Source Code

//package com.java2s;
/*//ww  w .  ja  va2s . co  m
 * Copyright (C) 2010-2014  Andreas Maier
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
*/

public class Main {
    /**
     * Returns the minimal and the maximal value in a given array
     * @param array the array
     * @return an array with minimal and maximal value
     */
    public static float[] minAndMaxOfArray(float[] array) {
        float[] revan = new float[2];
        revan[0] = Float.MAX_VALUE;
        revan[1] = -Float.MAX_VALUE;
        for (int i = 0; i < array.length; i++) {
            if (array[i] < revan[0]) {
                revan[0] = array[i];
            }
            if (array[i] > revan[1]) {
                revan[1] = array[i];
            }
        }
        return revan;
    }
}

Related

  1. min(T... values)
  2. min(T[] args)
  3. min(T[] inputArray, int i, int i0)
  4. min_max_mean_stddev(long[] counts)
  5. min_of_ints(int[] data)
  6. minarr(double[] a)
  7. minArray(int[] arr)
  8. minCeilDiv(int c, int... vals)
  9. minDiff(int... offs)