Returns the lesser of two values. - Java java.lang

Java examples for java.lang:Math Value

Description

Returns the lesser of two values.

Demo Code


//package com.java2s;

public class Main {
    /**/*from  w w  w.j a v a 2s.  c om*/
     * Returns the lesser of two values.
     * 
     * @param value1
     *        Source value.
     * @param value2
     *        Source value.
     * @return The lesser value.
     */
    public static float min(float value1, float value2) {
        return Math.min(value1, value2);
    }

    /**
     * Returns the lesser of two values.
     * 
     * @param value1
     *        Source value.
     * @param value2
     *        Source value.
     * @return The lesser value.
     */
    public static int min(int value1, int value2) {
        return value1 < value2 ? value1 : value2;
    }
}

Related Tutorials