Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Java Math acos() method with Examples

  • Last Updated : 05 Apr, 2018

The java.lang.Math.acos() returns the arc cosine of an angle in between 0.0 and pi. Arc cosine is also called as inverse of a cosine.If the argument is NaN or its absolute value is greater than 1, then the result is NaN.

Syntax :

public static double acos(double a)
Parameter :
a : the value whose arc cosine is to be returned.
Return :
This method returns the arc cosine of the argument.

Example :To show working of java.lang.Math.acos() method.

// Java program to demonstrate working
// of java.lang.Math.acos() method
import java.lang.Math;
class Gfg {
    // driver code
    public static void main(String args[])
        double a = Math.PI;
        // Output is NaN, because Math.PI gives 3.141 value
        // greater than 1
        // convert Math.PI to radians
        double b = Math.toRadians(a);
        double c = 1.0;
        double d = 0.0;
        double e = -1.0;
        double f = 1.5;
       // value of f does not lie in between -1 and 1 
       // so output is NaN


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!