Java .toRadians()
Published Oct 17, 2022Updated Oct 20, 2022
Contribute to Docs
The Math.toRadians()
method returns the measurement of an angle in degrees to an equivalent angle in radians.
Syntax
Math.toRadians(deg)
- The
deg
argument is adouble
value. - The conversion from degrees to radians is generally inexact.
Example
The following example uses Math.toRadians()
to convert 180 degrees and 45 degrees to radians:
public class Main {public static void main(String[] args) {double deg1 = 180.0;double deg2= 45.0;System.out.println(Math.toRadians(deg1));System.out.println(Math.toRadians(deg2));}}
This will produce the following output:
3.1415926535897930.7853981633974483
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly17 hours