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

Java examples for java.lang:Math Value

Description

Returns the greater of two values.

Demo Code


//package com.java2s;

public class Main {
    /**/* ww w .  jav  a2  s. co m*/
     * Returns the greater of two values.
     * 
     * @param value1
     *        Source value.
     * @param value2
     *        Source value.
     * @return The greater value.
     */
    public static float max(float value1, float value2) {
        return Math.max(value1, value2);
    }

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

Related Tutorials