Home » Java programming language

Java Math Class static double toRadians(double angle_in_degrees) with example

Java Math Class static double toRadians(double angle_in_degrees) method: Here, we are going to learn about the static double toRadians(double angle_in_degrees) method of Math Class with its syntax and example.
Submitted by Preeti Jain, on September 09, 2019

Math Class static double toRadians(double angle_in_degrees)

  • This method is available in java.lang package.
  • This method is used to convert the angle from degrees to radians or in other words we can say this method is used to convert an angle measured in degrees to an equivalent angle measured in radians.
  • This is a static method, it is accessible with the class name too.
  • The return type of this method is double, it returns the converted angle from degrees to radians of double type.
  • In this method, we pass only one parameter which represents an angle in the degrees form.
  • This method does not throw any exception.
  • The result of conversion an angle from degrees to radians is not generally exact.

Syntax:

    public static double toRadians(double angle_in_degrees){
    }

Parameter(s): angle_in_degrees – a ‘double’ type value which is an angel in the degrees.

Return value:

The return type of this method is double, it returns the converted value from degree to radians.

Java program to demonstrate example of toRadians(double angle_in_degrees) method

// Java program to demonstrate the example of 
// toRadians(double angle_in_degrees) method of Math Class.

public class ToRadiansMethod {
    public static void main(String[] args) {
        // declaring the variables
        double d1 = 60;
        double d2 = -60;
        double d3 = 90;
        double d4 = -90;

        // display the values
        System.out.println("Angel values in degrees...");
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);
        System.out.println("d3: " + d3);
        System.out.println("d4: " + d4);

        // converting the values from degree to radians
        d1 = Math.toRadians(d1);
        d2 = Math.toRadians(d2);
        d3 = Math.toRadians(d3);
        d4 = Math.toRadians(d4);

        System.out.println("Angel values in radians...");
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);
        System.out.println("d3: " + d3);
        System.out.println("d4: " + d4);
    }
}

Output

E:\Programs>javac ToRadiansMethod.java

E:\Programs>java ToRadiansMethod
Angel values in degrees...
d1: 60.0
d2: -60.0
d3: 90.0
d4: -90.0
Angel values in radians...
d1: 1.0471975511965976
d2: -1.0471975511965976
d3: 1.5707963267948966
d4: -1.5707963267948966





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.