Home >>Java Math Methods >Java Math.acos() method

Java Math.acos() method

Java Math.acos() method

Java Math.acos() is used to measure the angle of the trigonometric Arc Cosine. Sometimes called Arc cosine as an inverse of a cosine. This process gives back values between 0.0 and pi.

Syntax

public static double acos(double a)  

Parameters

a = This parameter is used to the value whose arc cosine is to be returned.

Returns

It is used to returns the arc cosine of the argument.

  1. This approach returns the Arc cosine value if the statement is positive or negative number.
  2. If the statement is -1 or beyond the -1 and 1 range this method returns -1.

Java Math.acos() Method Example 1


public class MyClass
{  
    public static void main(String[] args)   
    {  
        double x = 1.0;  
        System.out.println(Math.acos(x));  
    }  
} 

Output:
0.0

Java Math.acos() Method Example 2


public class MyClass  
{  
    public static void main(String[] args)   
    {  
        double x = -1.0;  
        System.out.println(Math.acos(x));  
    }  
}  

Output:
3.141592653589793

No Sidebar ads