Math radians to degrees conversion in java

This example shows you how to convert math’s radians into degree in java

The example below show you how to convert an angle measured in radians into degrees and vice versa. We can use the Math.toDegrees() and Math.toRadians() method call to do the conversion.

Below is the example of code.

package com.java.connect.math;
 
//Math radians to degrees conversion in java
public class MathRadiansToDegreeExample {
 
    public static void main(String[] args) {
        double radians = 5;
        double degrees = 35;
 
        // Converts an angle measured in radians to an
        // approximately equivalent angle measured in degrees.
        double toDegree = Math.toDegrees(radians);
 
        // Converts an angle measured in degrees to an
        // approximately equivalent angle measured in radians.
        double toRadians = Math.toRadians(degrees);
 
        System.out.println("The radians " + radians + " in degrees = "
                + toDegree);
        System.out.println("The degrees " + degrees + " in radians = "
                + toRadians);
    }
}

The output of the above code will be as:

The radians 5.0 in degrees = 286.4788975654116
The degrees 35.0 in radians = 0.6108652381980153