Java Array Min Value minMax(float[] array)

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

Description

Find the minimum and maximum values in an array.

License

Open Source License

Parameter

Parameter Description
array the array

Return

an array of two values, the first being the minimum and the second the maximum values found

Declaration

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

Method Source Code

//package com.java2s;

public class Main {
    /**// www .j a v a 2 s  .  c o m
     * <p>Find the minimum and maximum values in an array.</p>
     *
     * @param   array   the array
     * @return         an array of two values, the first being the minimum and the second the maximum values found
     */
    static public float[] minMax(float[] array) {
        float min = Float.MAX_VALUE;
        float max = Float.MIN_VALUE;
        for (float v : array) {
            if (v < min)
                min = v;
            if (v > max)
                max = v;
        }
        float[] returnValues = { min, max };
        return returnValues;
    }
}

Related

  1. minLengthCheck(final byte[] buffer, final byte length)
  2. minList(int[] listA, int[] listB)
  3. minLocation(double[] list)
  4. minmax(double[] a)
  5. minMax(float... values)
  6. minmax(int[] values)
  7. minMax(int[] values)
  8. minmax(String args[], boolean minimum)
  9. minMaxAvg(int[] arr)