Java StrictMath sin() Method with Example

StrictMath Class sin() method: Here, we are going to learn about the sin() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on December 27, 2019

StrictMath Class sin() method

• sin() method is available in java.lang package.
• sin() method is used to return the trigonometric sine of the given parameter in the method.
• In this method, sin stands for trigonometric sine of an angle".
• sin() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
• In this method we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of StrictMath class then after we will pass the same variable in sin() method).
• sin() method does not throw any exception at the time of returning trigonometric sine of an angle.

Syntax:

```    public static double sin(double d);
```

Parameter(s):

• double d – represents the value whose trigonometric sine is to be returned.

Return value:

The return type of this method is double – it returns the trigonometric sine of given angle.

Note:

• If we pass NaN, the method returns NaN.
• If we pass an infinity, the method returns NaN.
• If we pass a value whose absolute value is 0, the method returns 0.

Example:

```// Java program to demonstrate the example of
// sin(double d) method of StrictMath class.

public class Sin {
public static void main(String[] args) {
// variable declarations
double a1 = 100;
double a2 = Math.PI / 2;
double a3 = 0;

// Display previous value of a1, a2 and a3
System.out.println("a1: " + a1);
System.out.println("a2: " + a2);
System.out.println("a3: " + a3);

// By using toRadians() method is used to convert absolute to radians

// Display the value of a2 in radians form

// Here we will find trignometric sine of a2
// by using sin() method
System.out.println("StrictMath.sin(a2): " + StrictMath.sin(a2));

// Here , we will get 0 because we are passing parameter
// whose absolute value is 0
System.out.println("StrictMath.sin(a3): " + StrictMath.sin(a3));
}
}
```

Output

```a1: 100.0
a2: 1.5707963267948966
a3: 0.0
StrictMath.sin(a2): 0.027412133592044294
StrictMath.sin(a3): 0.0
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates