Java Array Min Value minValue(final int[] arr)

Here you can find the source of minValue(final int[] arr)

Description

Returns the smallest value in the array.

License

Apache License

Parameter

Parameter Description
arr array of #t#

Return

the value

Declaration

public static int minValue(final int[] arr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  ww w.ja v a  2s.  c o m*/
     * Returns the smallest value in the array.
     * 
     * @param arr
     *            array of #t#
     * @return the value
     */
    public static int minValue(final int[] arr) {
        if (arr.length < 0)
            return 0;

        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i];
            }
        }

        return min;
    }

    /**
     * Returns the smallest value in the array.
     * 
     * @param arr
     *            array of #t#
     * @return the value
     */
    public static float minValue(final float[] arr) {
        if (arr.length < 0)
            return 0;

        float min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i];
            }
        }

        return min;
    }
}

Related

  1. minsort(int[] vet1)
  2. minValue(double array[][])
  3. minValue(double[] from)
  4. minValue(double[] values)
  5. minValue(double[] values)
  6. minValue(float[] arr)
  7. minValue(int[] array)
  8. minValue(int[] values)
  9. minValue(long[] array)