Java Math acos() Method

tutorial and example
tutorial and example

The acos() method of Math class computes the trigonometric Arc Cosine (inverse of cosine ) of an angle. The value returned is between 0.0 to pi.

Syntax:

public static double acos(double a)

Parameters:

The parameter ‘a’ represents the value whose arc cosine is to be determined.

Return Value:

The acos() method returns the arc cosine of the argument .

  • If we pass a positive or negative argument which is in between the range of -1 to 1, it will return the arc cosine value.
  • If we pass an argument which is smaller than -1 and greater than 1, it will return NaN.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output: