Thursday, October 9, 2025
HomeLanguagesJavatoDegrees() and toRadians() in Java

toDegrees() and toRadians() in Java

toDegrees() is an inbuilt method in java that converts argument value to degrees.

Syntax:

 Math.toDegrees(double d)

Parameters:
The parameter is mandatory and has to be of a double data type. The passed parameter is thus converted to degrees.

Returns
It returns a value of data-type. The passed argument gets converted to degrees and is returned.

Code#1: Program explaining the implementation of toDegrees()




// Java program for implementation of
// toDegrees() method
import java.util.*;
class GFG {
  
    // Driver Code
    public static void main(String args[])
    {
        double x = 12.0;
        double y = 19.0;
  
        // conversion of number to degrees using
        // inbuilt function
        double xinDegrees = Math.toDegrees(x);
        double yinDegrees = Math.toDegrees(y);
  
        // Prints the number in degrees
        System.out.println(xinDegrees);
        System.out.println(yinDegrees);
    }
}


Output:

687.5493541569879
1088.619810748564

Output:

687.5493541569879
1088.619810748564

toRadians() is an inbuilt method in java that converts argument value to radian.

Syntax:

 Math.toRadians(double d)

Parameters:
The parameter is mandatory and has to be of a double data type. The passed parameter is thus converted to radians.

Returns
It returns a value of data-type. The passed argument gets converted to radians and is returned.

Code#2: Program explaining the implementation of toRadians()




// Java program for implementation of
// toRadians() method
import java.util.*;
class GFG {
  
    // Driver Code
    public static void main(String args[])
    {
        double x = 12.0;
        double y = 19.0;
  
        // conversion of number to Radians using
        // inbuilt function
        double xinRadians = Math.toRadians(x);
        double yinRadians = Math.toRadians(y);
  
        // Prints the number in Radians
        System.out.println(xinRadians);
        System.out.println(yinRadians);
    }
}


Output:

0.20943951023931953
0.33161255787892263
RELATED ARTICLES

Most Popular

Dominic
32346 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7095 POSTS0 COMMENTS
Thapelo Manthata
6790 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS