Java Number Max Value max(Integer i1, Integer i2)

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

Description

Returns the bigger of the two Integers.

License

MIT License

Parameter

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

Return

the bigger of the two Integers.

Declaration

public static Integer max(Integer i1, Integer i2) 

Method Source Code

//package com.java2s;
/*/*from   www  .  j av  a  2s .  c  om*/
 * Copyright (c) 2013-2017 QuartzDesk.com.
 * Licensed under the MIT license (https://opensource.org/licenses/MIT).
 */

public class Main {
    /**
     * Returns the bigger 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 bigger of the two Integers.
     */
    public static Integer max(Integer i1, Integer i2) {
        if (i1 != null && i2 != null)
            return i1 > i2 ? i1 : i2;

        return i1 == null ? i2 : i1;
    }

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

Related

  1. max(int i, int j, int k)
  2. max(int idx, int orderFrom, int orderTo)
  3. max(int x, int x2, int x3)
  4. max(int x, int y)
  5. max(Integer a, Integer b)
  6. max(Iterable nums)
  7. max(long a, long b)
  8. max(Number a, Number b)
  9. max(Number n0, Number n1)