StrictMath.max(int, int) in Java

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

Syntax:

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

This method takes two arguments of type int as its parameters. This method returns the greater of two int values. That is, the result is the argument closer to the value of Integer.MAX_VALUE.

Note:

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

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 StrictMathmaxint {
    public static void main(String[] args) {

        int a = 25, b = 22;
        System.out.println(StrictMath.max(a, b));
    }
}

Output:

25


Some more max() Methods of StrictMath class


StrictMath.max(double, double)


StrictMath.max(float, float)


StrictMath.max(long, long)



No comments:

Post a Comment