Java Tutorial Java Advanced Java References

Java Math - toRadians() Method



The Java toRadians() method returns an angle measured in degrees to an approx. equivalent angle measured in radians.

Syntax

public static double toRadians(double angdeg)

Parameters

angdeg Specify an angle in degrees.

Return Value

Returns the angle measured in radians.

Exception

NA.

Example:

In the example below, toRadians() method returns an angle measured in degrees into angle measured in radians.

public class MyClass {
 public static void main(String[] args) {
  System.out.println(Math.toRadians(30)); 
  System.out.println(Math.toRadians(60)); 
  System.out.println(Math.toRadians(90)); 
  System.out.println(Math.toRadians(120));     
 }
}

The output of the above code will be:

0.5235987755982988
1.0471975511965976
1.5707963267948966
2.0943951023931953

❮ Java Math Methods