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 = 0.52;
double angle2 = 0.79;
System.out.println(Math.toDegrees(angle1)); // 29.79380534680281
System.out.println(Math.toDegrees(angle2)); // 45.26366581533504
}
}