# Java Math class toDegrees() method with example

Math class toDegrees() method in Java: Here, we are going to learn about the toDegrees() method of Math class in Java programming language with its syntax and example.
Submitted by Preeti Jain, on September 16, 2019

## Math class toDegrees() method

• toDegrees() method is available in java.lang package.
• toDegrees() method is used to convert an angle from radians to degrees.
• toDegrees() method is a static method, it is accessible with the class name too.
• toDegrees() method does not throw any exception.

Note: The result of conversion an angle from radians to degrees is not generally exact.

Syntax:

```    public static double toDegrees(double angle_in_radians);
```

Parameter(s):

Return value:

The return type of this method is double – it returns the converted angle from radians to degrees.

### Java program to demonstrate example of toDegrees() method

```// Java program to demonstrate the example of
// toDegrees(double angle_in_radians) method of Math Class

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

// displaying the values
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);
System.out.println("d3: " + d3);
System.out.println("d4: " + d4);

// converting angel value from radians to degrees
d1 = Math.toDegrees(d1);
d2 = Math.toDegrees(d2);
d3 = Math.toDegrees(d3);
d4 = Math.toDegrees(d4);

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);
}
}
```

Output

```E:\Programs>javac ToDegreesMethod.java
E:\Programs>java ToDegreesMethod
d1: 60.0
d2: -60.0
d3: 90.0
d4: -90.0
Angel values in degrees...
d1: 3437.746770784939
d2: -3437.746770784939
d3: 5156.620156177409
d4: -5156.620156177409
```

TOP Interview Coding Problems/Challenges

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