Java Number Min Value min(Integer i1, Integer i2)

Here you can find the source of min(Integer i1, Integer i2)

Description

Returns the smaller of the two Integers.

License

MIT License

Parameter

Parameter Description
i1 the first Integer.
i2 the second Integer.

Return

the smaller of the two Integers.

Declaration

public static Integer min(Integer i1, Integer i2) 

Method Source Code

//package com.java2s;
/*//www.ja va2s . c o m
 * Copyright (c) 2013-2017 QuartzDesk.com.
 * Licensed under the MIT license (https://opensource.org/licenses/MIT).
 */

public class Main {
    /**
     * Returns the smaller of the two Integers. A null Integer
     * is treated as smaller then {@link Integer#MIN_VALUE}.
     *
     * @param i1 the first Integer.
     * @param i2 the second Integer.
     * @return the smaller of the two Integers.
     */
    public static Integer min(Integer i1, Integer i2) {
        if (i1 != null && i2 != null)
            return min(i1.intValue(), i2.intValue());

        return null;
    }

    /**
     * Returns the smaller value of the two int arguments.
     *
     * @param i1 the first int.
     * @param i2 the second int.
     * @return the smaller value of the two int arguments.
     */
    public static int min(int i1, int i2) {
        return i1 < i2 ? i1 : i2;
    }

    /**
     * Returns the smaller of the two Doubles. A null Double
     * is treated as smaller then {@link Double#MIN_VALUE}.
     *
     * @param d1 the first Double.
     * @param d2 the second Double.
     * @return the smaller of the two Doubles.
     */
    public static Double min(Double d1, Double d2) {
        if (d1 != null && d2 != null)
            return min(d1.doubleValue(), d2.doubleValue());

        return null;
    }

    /**
     * Returns the smaller value of the two double arguments.
     *
     * @param d1 the first double.
     * @param d2 the second double.
     * @return the smaller value of the two double arguments.
     */
    public static double min(double d1, double d2) {
        return d1 < d2 ? d1 : d2;
    }
}

Related

  1. min(int value, int min)
  2. min(int x, int x2, int x3)
  3. min(int x, int y)
  4. min(int x, int y)
  5. min(Integer a, Integer b)
  6. min(long m, long n)
  7. min(long x, long y)
  8. min(Number a, Number b)
  9. min(Number n0, Number n1)