get Min from double array - Java Collection Framework

Java examples for Collection Framework:Array Algorithm

Description

get Min from double array

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        double[] array = new double[] { 34.45, 35.45, 36.67, 37.78,
                37.0000, 37.1234, 67.2344, 68.34534, 69.87700 };
        System.out.println(getMin(array));
    }//from   w  w w.j  a v a  2 s . c  o  m

    public static double getMin(double[] array) {
        double min = Double.MAX_VALUE;
        for (int i = 0; i < array.length; i++) {
            if (array[i] < min) {
                min = array[i];
            }
        }
        return min;
    }
}

Related Tutorials