Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java tan() Method

Java tan() Method

Java Number ClassThe Java Number class


The tan() method returns the tangent of the specified double argument.

Syntax



double tan(double d)

Parameters

Return Value

Returns the tangent of the specified double argument.

Example



public class Test{

    public static void main(String args[]){



        double degrees = 45.0;

        double radians = Math.toRadians(degrees);



        System.out.format("pi 的值为 %.4f%n", Math.PI);

        System.out.format("%.1f 度的正切值是 %.4f%n", degrees, Math.tan(radians));



    }

}

Compile the above program; the output is:



pi 的值为 3.1416

45.0 度的正切值是 1.0000


Java Number ClassThe Java Number class