Java Math convert degree to radian and convert radian to degree

Introduction

The following program demonstrates toRadians() and toDegrees():


// Demonstrate toDegrees() and toRadians().
public class Main {
  public static void main(String args[]) {
    double theta = 120.0;

    System.out.println(theta + " degrees is " +
                       Math.toRadians(theta) + " radians.");

    theta = 1.312;// w  w w .j a v a2 s.c om
    System.out.println(theta + " radians is " +
                       Math.toDegrees(theta) + " degrees.");
  }
}



PreviousNext

Related