Facebook Page Twitter Page LinkedIn Page
× Java Tutorial Java Advanced Java Resources


The Java Math sin() method is used to return trigonometric sine of an angle (angle should be in radians). In special cases it returns the following:

  • If the argument is NaN or an infinity, then the result is NaN.
  • If the argument is zero, then the result is a zero with the same sign as the argument.

Syntax

public static double sin(double arg)

Parameters

arg Specify the angle in radian.

Return Value

Returns the trigonometric sine of an angle.

Exception

NA.

Example:

In the below example, sin() method is used to find out the trigonometric sine of an angle.

public class MyClass {
 public static void main(String[] args) {
  System.out.println(Math.sin(Math.PI/6));   
  System.out.println(Math.sin(Math.PI/4));
  System.out.println(Math.sin(Math.PI/3));     
 }
}

The output of the above code will be:

0.49999999999999994
0.7071067811865475
0.8660254037844386

❮ Java Math Methods