Java Number Max Value max(final int a, final int b)

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

Description

Return the greater of the two values.

License

Creative Commons License

Parameter

Parameter Description
a First value.
b Second value.

Return

Larger value.

Declaration

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

Method Source Code

//package com.java2s;
/**/*w w  w .  j ava 2 s.  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 greater of the two values.
     * @param a First value.
     * @param b Second value.
     * @return Larger value.
     */
    public static short max(final short a, final short b) {
        return (a >= b ? a : b);
    }

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

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

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

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

Related

  1. max(double x0, double x1, double x2)
  2. max(final double a, final double b, final double c)
  3. max(final float a, final float b)
  4. max(final float a, final float b)
  5. max(final float a, final float b, final float c)
  6. max(final int a, final int b)
  7. max(final Iterable numbers)
  8. max(final Iterable values)
  9. max(final NUMBER_TYPE n1, final NUMBER_TYPE n2)