toRadians() in Java

toRadians(): This method is available in the Math class of Java.

Syntax:

double java.lang.Math.toRadians(double angdeg)

This method takes one argument of type double as its parameter. This method converts an angle measured in degrees to an approximately equivalent angle measured in radians.

Parameters: One parameter is required for this method.

angdeg: an angle, in degrees.

Returns: the measurement of the angle angdeg in radians.

For Example:

Math.toRadians(180.0) = > It returns 3.141592653589793

Approach

Java

public class ToRadians {
    public static void main(String[] args) {

        double angdeg = 180.0;
        System.out.println(Math.toRadians(angdeg));

    }
}

Output:

3.141592653589793

No comments:

Post a Comment