Convert angle in degrees to radians in Java

static double toRadians(double angleind) of Math class can be used to convert angle from degrees to radians.

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 degrees=150;

double degtor=Math.toRadians(degrees);

System.out.println("Degree equivalent of "+degrees+" is "+degtor);

}

}

Output 1

Degree equivalent of 150.0 is 2.6179938779914944


Example 2

class MathTest{

public static void main(String args[]){

double deg=52;

double degtor=Math.toRadians(deg);

System.out.println("Degree equivalent of "+deg+" is "+degtor);

}

}

Output 2

Degree equivalent of 52.0 is 0.9075712110370513