Returns the minimum value of some list of doubles. - Java java.lang

Java examples for java.lang:double Array

Description

Returns the minimum value of some list of doubles.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        double vals = 2.45678;
        System.out.println(min(vals));
    }//from  w  w w  .ja v  a  2s  . co  m

    /**
     * Returns the minimum value of some list of doubles.
     * @param vals
     * @return
     */
    public static final double min(double... vals) {
        double min = Double.MAX_VALUE;

        for (double v : vals)
            if (v < min)
                min = v;

        return min;
    }
}

Related Tutorials