toRadians() and toDegrees() Sample program in Java

By: Ivan Lim  

The toRadians() method converts degrees to radians. toDegrees() converts radians to degrees. Here is a program that demonstrates toRadians() and toDegrees():

// Demonstrate toDegrees() and toRadians().
class Angles {
public static void main(String args[]) {
double theta = 120.0;
System.out.println(theta + " degrees is " +
Math.toRadians(theta) + " radians.");
theta = 1.312;
System.out.println(theta + " radians is " +
Math.toDegrees(theta) + " degrees.");
}
}

The output is shown here.

120.0 degrees is 2.0943951023931953 radians.
1.312 radians is 75.17206272116401 degrees.




Archived Comments

1. Actually, 120º *is* 2.0943951023931953 radians because 180º is pi radians (i
View Tutorial          By: Stephen Blythe at 2012-04-02 03:39:03

2. NO NO NO!!
120º not is 2.0943951023931953 radians wtf?
180º i

View Tutorial          By: jsError at 2012-02-05 22:46:15


Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial