Java Data Type Tutorial - Java Math.toRadians(double angdeg)








Syntax

Math.toRadians(double angdeg) has the following syntax.

public static double toRadians(double angdeg)

Example

In the following code shows how to use Math.toRadians(double angdeg) method.

//from ww w .  j  a  v a 2  s  . c  o  m

public class Main {

   public static void main(String[] args) {

      double x = 45;
      double y = -180;

      // convert them in radians
      x = Math.toRadians(x);
      y = Math.toRadians(y);

      System.out.println(x);
      System.out.println(y);

   }
}

The code above generates the following result.