Home >>Java Math Methods >Java Math.toRadians() method

Java Math.toRadians() method

Java Math.toRadians() method

Java Math.toRadians() in Java Math is used to an integrated math function in java that is used to convert an angle measured in degrees to an approximately equivalent angle measured in radians.

Syntax

public static double toRadians(double x)  

Parameter

x = This parameter is used for an angle, in degrees

Return

It is used to returns the measurement of the angle x in radians.

  1. This method returns -1 if the statement is -1.
  2. When the argument is negative, the method returns negative with the same sign as the argument.
  3. If the argument is infinity, with the same sign as the argument this method will return infinity.

Java Math.toRadians() method Example 1


public class MyClass 
{  
public static void main(String[] args)   
{  
double a = 45.0;  
System.out.println(Math.toRadians(a));  
}  
}  

Output:
0.7853981633974483

Java Math.toRadians() method Example 2


public class MyClass  
{  
public static void main(String[] args)   
{  
double a = Double.MAX_VALUE;  
System.out.println(Math.toRadians(a));  
}  
}  

Output:
3.1375664143845866E306