# Java StrictMath tan() Method with Example

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

## StrictMath Class tan() method

• tan() method is available in java.lang package.
• tan() method is used to return the trigonometric tangent of an angle of the given parameter in the method. Here, “tan” stands for the trigonometric tangent of an angle.
• tan() method is a static method so 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 tan() 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 tan() method).
• tan() method does not throw any exception at the time of returning tangent of an angle.

Syntax:

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

Parameter(s):

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

Return value:

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

Note:

• If we pass NaN, the method returns NaN.
• If we pass an infinity (positive or negative), the method returns the same value.
• If we pass a zero (positive or negative), the method returns the same value with the same sign.

Example:

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

public class Tan {
public static void main(String[] args) {
// variable declarations
double d1 = -0.0;
double d2 = Math.PI / 2;

// Display previous value of d1 and d2
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);

// Here , we will get (-0.0) because we are passing parameter
// whose absolute value is -0.0
System.out.println("StrictMath.tan(d1): " + StrictMath.tan(d1));

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

// Display the value of d2 in radians form
System.out.println("d2: " + d2);

// Here we will find trignometric tangent of d2 by using tan() method
System.out.println("StrictMath.tan(d2): " + StrictMath.tan(d2));
}
}
```

Output

```d1: -0.0
d2: 1.5707963267948966
StrictMath.tan(d1): -0.0
d2: 0.027415567780803774
StrictMath.tan(d2): 0.02742243848209777
```

TOP Interview Coding Problems/Challenges

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