Convert angle in radians to degrees in Java
static double toDegrees(double angleinr) of Math class can be used to convert angle from radians to degrees.
The method since it is static, can be called directly using the class name. The class belongs to package java.lang.
Example 1
class MathTest{
public static void main(String args[]){
double radians=2.33;
double radtode=Math.toDegrees(radians);
System.out.println("Degree equivalent of "+radians+" is "+radtode);
}
}
Output 1
Degree equivalent of 2.33 is 133.49916626548182
Example 2
class MathTest{
public static void main(String args[]){
double rad=6.28;
double radtode=Math.toDegrees(rad);
System.out.println("Degree equivalent of "+rad+" is "+radtode);
}
}
Output 2
Degree equivalent of 6.28 is 359.81749534215703