Friday, June 19, 2026
HomeLanguagesJavaJava toRadians() method with Example

Java toRadians() method with Example

The java.lang.Math.toRadians() is used to convert an angle measured in degrees to an approximately equivalent angle measured in radians. 
Note: The conversion from degrees to radian is generally inexact.
 

Syntax:  

public static double toRadians(double deg)

Parameter:
deg : This parameter is an angle in degrees which
we want to convert in radians.
Return :
This method returns the measurement of the angle 
deg in radians.

Example: To show working of java.lang.Math.toRadians() method. 

Java




// Java program to demonstrate working
// of java.lang.Math.toRadians() method
import java.lang.Math;
 
class Gfg {
 
    // driver code
    public static void main(String args[])
    {
        // converting PI from degree to radian
        double deg = 180.0;
        System.out.println(Math.toRadians(deg));
 
        // converting PI/2 from degree to radian
        deg = 90.0;
        System.out.println(Math.toRadians(deg));
 
        // converting PI/4 from degree to radian
        deg = 45.0;
        System.out.println(Math.toRadians(deg));
    }
}


Output: 

3.141592653589793
1.5707963267948966
0.7853981633974483
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6899 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6965 POSTS0 COMMENTS