Java acos () method
acos () method returns the type parameter to specify double inverse cosine.
grammar
double acos(double d)
parameter
d - any native data types.
return value
Returns the double value of the type parameter of the inverse cosine.
Examples
public class Test{ public static void main(String args[]){ double degrees = 45.0; double radians = Math.toRadians(degrees); System.out.format("pi 的值为 %.4f%n", Math.PI); System.out.format("%.4f 的反余弦值为 %.4f 度 %n", Math.cos(radians), Math.toDegrees(Math.acos(Math.sin(radians)))); } }
Compile the above program, the output is:
pi 的值为 3.1416 0.7071 的反余弦值为 45.0000 度