# Java StrictMath acos() method with example

StrictMath Class acos() method: Here, we are going to learn about the acos() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on December 25, 2019

## StrictMath Class acos() method

• acos() method is available in java.lang package.
• acos() method is used to return the arc cosine of the given parameter in the method. Here, acos stands for "arc cosine" of an angle.
• acos() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
• In this method, we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of Math class then after we will pass the same variable in acos() method).
• acos() method does not throw any exception.
• In this method, the meaning of arc cosine is the inverse or reverse cosine of the given argument.
• The range of acos() lies 0.0 through PI.

Syntax:

```    public static double acos(double d);
```

Parameter(s):

• double d – represents a double type value whose arc cosine value to be found.

Return value:

The return type of this method is double – it returns the arc cosine of given angle.

Note:

• If we pass NaN as an argument, method returns the same value (NaN).
• If we pass an argument whose absolute value is greater than 1, method returns NaN.

Example:

```// Java program to demonstrate the example
// of  acos(double d) method of StricMath Class.

public class Acos {
public static void main(String[] args) {
// variable declarations
double a1 = 100;
double a2 = Math.PI / 2;

// Display previous value of a1 and a2
System.out.println("a1 :" + a1);
System.out.println("a2:" + a2);

// Here , we will get NaN because we are
// passing parameter whose absolute value is greater
// than 1
System.out.println("StrictMath.acos(a1): " + StrictMath.acos(a1));

// By using toRadians() method is used to convert absolute to radians

// Display the value of a2 in radians form

// Here we will find arc cosine of a2 by using acos() method
System.out.println("StrictMath.acos(a2): " + StrictMath.acos(a2));
}
}
```

Output

```a1 :100.0
a2:1.5707963267948966
StrictMath.acos(a1): NaN
StrictMath.acos(a2): 1.5433773235341761
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates