// calculating cosine double cosine = Math.cos(45); // calculating sine double sine = Math.sin(45); // calculating tangent double tangent = Math.tan(45);
The Math class found in the java.lang package has methods for easily calculating all the trigonometric functions. In this phrase, we show how you can easily determine the cosine, sine, and tangent of a given angle. The Math class also has methods for calculating the arc cosine, arc sine, and arc tangent, as well as the hyperbolic sine, cosine, and tangent. Each of these methods accepts a single input parameter of double type and returns a result type of double.