StrictMath.max(float, float) in Java

StrictMath.max(float, float): This method is available in java.lang.StrictMath class of Java.

Syntax:

float java.lang.StrictMath.max(float a, float b)

This method takes two arguments of type float as its parameters. This method returns the greater of two float values. That is, the result is the argument is closer to positive infinity.

Note:

1. If the arguments have the same value, the result is the same value.

2. If either value is NaN, then the result is NaN.

Parameters: Two parameters are required for this method.

a: an argument.

b: another argument.

Returns: the larger of a and b.

Exceptions: NA

Approach

Java

public class StrictMathmaxfloat {
    public static void main(String[] args) {

        float a = 19.9f, b = 197.56f;
        System.out.println(StrictMath.max(a, b));
    }
}

Output:

197.56


Some more max() Methods of StrictMath class


StrictMath.max(double, double)


StrictMath.max(int, int)


StrictMath.max(long, long)


No comments:

Post a Comment