Java Math toDegrees()

The Java Math toDegrees() method converts the specified angle measured in radians into degrees.

The syntax of the toDegrees() method is:

Math.toDegrees(double angle)

Here, toDegrees() is a static method. Hence, we are accessing the method using the class name, Math.


toDegrees() Parameters

The toDegrees() method takes a single parameter.

  • angle - angle radians which is to be converted to degrees

toDegrees() Return Value

  • returns the angle measured in degrees

Note: The conversion from radians to degrees is approximate. However, it is generally inexact.


Example: Java Math.toDegrees()

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

    // create variables
    double angle1 = 30.0;
    double angle2 = 45.0;

    System.out.println(Math.toRadians(angle1));  // 0.5235987755982988
    System.out.println(Math.toRadians(angle2));  // 0.7853981633974483
  }
}

Recommended Tutorials