Java Number Min Value min(final int a, final int b)

Here you can find the source of min(final int a, final int b)

Description

Return the lesser of the two values.

License

Creative Commons License

Parameter

Parameter Description
a First value.
b Second value.

Return

Larger value.

Declaration

public static int min(final int a, final int b) 

Method Source Code

//package com.java2s;
/**/*from w  w  w. j av a 2s  . com*/
 * Static helper class to centralize various useful methods
 * that do not fit in any other util.
 * Copyright (c) 2015 Vinland Solutions
 * Creative Commons Attribution-NonCommercial <http://creativecommons.org/licenses/by-nc/3.0/deed.en_US>
 * @author JayJeckel <http://minecraft.jeckelland.site88.net/>
 */

public class Main {
    /**
     * Return the lesser of the two values.
     * @param a First value.
     * @param b Second value.
     * @return Larger value.
     */
    public static short min(final short a, final short b) {
        return (a <= b ? a : b);
    }

    /**
     * Return the lesser of the two values.
     * @param a First value.
     * @param b Second value.
     * @return Larger value.
     */
    public static int min(final int a, final int b) {
        return (a <= b ? a : b);
    }

    /**
     * Return the lesser of the two values.
     * @param a First value.
     * @param b Second value.
     * @return Larger value.
     */
    public static long min(final long a, final long b) {
        return (a <= b ? a : b);
    }

    /**
     * Return the lesser of the two values.
     * @param a First value.
     * @param b Second value.
     * @return Larger value.
     */
    public static float min(final float a, final float b) {
        return (a <= b ? a : b);
    }

    /**
     * Return the lesser of the two values.
     * @param a First value.
     * @param b Second value.
     * @return Larger value.
     */
    public static double min(final double a, final double b) {
        return (a <= b ? a : b);
    }
}

Related

  1. min(double v1, double v2, double v3, double v4)
  2. min(double x, double y)
  3. min(final float a, final float b)
  4. min(final float a, final float b)
  5. min(final float a, final float b, final float c)
  6. min(final int a, final int b)
  7. min(final Iterable numbers)
  8. min(final NUMBER_TYPE n1, final NUMBER_TYPE n2)
  9. min(final NUMBER_TYPE number1, final NUMBER_TYPE number2)