StrictMath.abs(long) in Java

StrictMath.abs(long): This method is available in java.lang.StrictMath class of Java.

Syntax:

long java.lang.StrictMath.abs(long a)

This method takes one argument of type long as its parameter. This method returns the absolute value of a long value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

Parameters: One parameter is required for this method.

a: the argument whose absolute value is to be determined.

Returns: the absolute value of the argument.

Exceptions: NA

Approach

Java

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

        long a = -1788901901;
        System.out.println(StrictMath.abs(a));
    }
}

Output:

1788901901


No comments:

Post a Comment