Home >>Java Math Methods >Java Math.sin() method

Java Math.sin() method

Java Math.sin() method

The Math.sin() method in Java Math is used to return the angle sine in trigonometry. This method returns the value between -1 to 1.

Syntax:

public static double sin(double a)

Parameter

a = This parameter is used for an angle, in radians

Return

It is used to returns the sine value of the argument.

  1. If the argument is positive or negative number, then this method returns the value of the Sine.
  2. If NaN or infinity is the argument, the method will return NaN.
  3. When the argument is zero, the method returns zero with the same sign as the argument.
Java Math.sin() method Example 1

public class MyClass   
{  
public static void main(String[] args)   
{  
double x = 20;  
double y = Math.toRadians(x);  
System.out.println(Math.sin(y));  
}  
}  

Output:-
0.3420201433256687
Java Math.sin() method Example 2

public class MyClass  
{  
public static void main(String[] args)   
{  
double x = 45;  
double y = Math.toRadians(x);  
System.out.println(Math.sin(y));  
}  
}  

Output:-
0.7071067811865475

No Sidebar ads