Java tan Function

The Java tan Function is one of the Java Math Library function which is used to calculate the Trigonometry Tangent for the specified expression.

In this article we will show you, How to use Java Math.tan function with example. Before we get into Java program, Let us see the mathematical formula behind the Trigonometry Tangent function is as shown below:

Within this Java tan function example, First, We declared variable x of type Double and used the Java Math.tan function directly on expression. Here, we used System.out.println statement to print the tangent result as output.

Next, We declared variable of type Double and assigned the value. Here, we used the Math.toRadians function to convert 90 into equivalent radiant. Lastly, we used Java Math.tan Function inside the System.out.println statement to find the tangent value of radiant 90 and print the result as output.

Next, We used the Java For Loop to iterate the Array. Within the For Loop, we initialized the i value as 0. Next, compiler will check for the condition (i < myArray.length). Statement inside the for loop will be executed until the condition is Flase.

TIP: myArray.length is used to find the length of an array.

for (int i = 0; i < myArray.length; i++) {

Following statements will print the output. If you observe the code snippet, we used the Math.tan Function directly inside the System.out.format statement. Here, compiler will call the Math.tan method ( static double tan(double number) ) to find the corresponding Tangent values.