Java Math cos() method with Examples
The java.lang.Math.cos() returns the trigonometric cosine of an angle. If the argument is NaN or an infinity, then the result returned is NaN. The returned value will be in range [-1, 1].
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public static double cos(double angle) Parameters: The function has one mandatory parameter angle which is in radians.
The function returns the trigonometric cosine of an angle.
Example 1 : To show working of java.lang.Math.cos() method.
0.8660254037844387 0.7071067811865476 0.5000000000000001 1.0
Example 2 : To show working of java.lang.Math.cos() method when argument is NAN or infinity.
NaN NaN NaN