Java Math cos() Method

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

Syntax:

public static double cos(double a)

Parameters:

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:

 Output:

Example 2:

 Output:

Example 3:

 Output:

Example 4:

 Output: