Close

Java - Math.acos() Examples

Java Java API 


Class:

java.lang.Math

java.lang.Objectjava.lang.Objectjava.lang.Mathjava.lang.MathLogicBig

Method:

public static double acos(double a)

Returns the arc cosine of a value in radians.

Parameters:
a - the value whose arc cosine is to be returned.
Returns:
the arc cosine of the argument.


Examples


package com.logicbig.example.math;

public class AcosExample {

public static void main(String... args) {
findArcCosine(-1);
findArcCosine(0);
findArcCosine(0.5);
findArcCosine(0.866);
findArcCosine(1);
}

private static void findArcCosine(double value) {
double cosValue = Math.acos(value);
double degree = Math.toDegrees(cosValue);
System.out.printf("ArcCosine of %s = %1.2f degree%n", value, degree);
}
}

Output

ArcCosine of -1.0 = 180.00 degree
ArcCosine of 0.0 = 90.00 degree
ArcCosine of 0.5 = 60.00 degree
ArcCosine of 0.866 = 30.00 degree
ArcCosine of 1.0 = 0.00 degree




See Also