Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Java – Find Sine of Angle – sin() Method – Examples & Explanation

sin() method is used to find out a trigonometric ratio sine of an angle in JAVA, measured in radians. sin() method exists in “Math” library of JAVA programming language.

Syntax of sin() Method in JAVA

The syntax of sin() method in JAVA Language is:


Arguments of sin() method in JAVA

x – Where x is any valid java double value (represents an angle), measured in radian.


Error Handling

If the x parameter is not a number sin() method returns an error.
If argument is empty or no argument is used, sin() method returns an error


Return Value of sin() method in JAVA

sin() method returns numeric value (double) after calculating sine of given argument (angle), in radian.
if argumment (X) is NaN, sin() method returns NaN.
if argumment (X) is infinity, sin() method returns NaN.
if argumment (X) is zero, sin() method returns Zero (Positive or negative with the same sign as argument).
Note: The return value must be within 1 ulp (unit of the last place unit of least precision) of the exact return value and return value must be semi-monotonic.


sin() Method example in JAVA when argument is a numeric value



sin() Method Example in Java when argument = zero



Sin() Method Example in when argument is a string

The above code example returns an error because of incompatible data type. The string type cannot be converted into double.


LearnAndLearn.com © 2018 - All rights reserved