Gets the minimum value in the array. - Java Collection Framework

Java examples for Collection Framework:Array Search

Description

Gets the minimum value in the array.

Demo Code


//package com.java2s;

public class Main {
    /**/*from www  .  jav  a2s  .  c  o  m*/
     * Gets the minimum value in the array.
     * @param input
     * @return
     */
    public static double min(double[] input) {
        double min = Double.MAX_VALUE;
        for (int i = 0; i < input.length; i++) {
            if (input[i] < min) {
                min = input[i];
            }
        }
        return min;
    }
}

Related Tutorials