Java Math cos() Method

The cos() method of Math class returns the trigonometric cosine of the specified angle.


public static double cos(double a)


The parameter ‘a’ represents an angle measured in radians.

Return Value:

The cos() method returns the cosine of the argument. It returns NaN, for NaN or infinity argument.

Example 1:


Example 2:


Example 3:


Example 4: