Java has a built-in Math class, defined in the java.lang package, which contains important functions to perform basic mathematical operations. The class has the sin() method, which is used to compute a specified angle’s trigonometric sine.
public static double sin(double angle);
angle represents the double value corresponding to the angle in radians, of which we have to find the sine.angle.If the value of angle is infinity or NaN.
To convert an angle measured in degrees to an equivalent angle measured in radians, we can use the built-in method
Math.toRadians(double angle_in_degrees).
import java.lang.Math;class HelloWorld {public static void main( String args[] ) {double param = Math.toRadians(30);double result = Math.sin(param);System.out.println("sin(" + param + ") = " + result);param = Math.toRadians(45);result = Math.sin(param);System.out.println("sin(" + param + ") = " + result);param = Math.toRadians(60);result = Math.sin(param);System.out.println("sin(" + param + ") = " + result);param = Math.toRadians(90);result = Math.sin(param);System.out.println("sin(" + param + ") = " + result);result = Math.sin(Double.POSITIVE_INFINITY);System.out.println("sin(∞) = " + result);result = Math.sin(Double.NaN);System.out.println("sin(NaN) = " + result);}}