# Java StrictMath toDegrees() Method with Example

StrictMath Class toDegrees() method: Here, we are going to learn about the toDegrees() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on December 27, 2019

## StrictMath Class toDegrees() method

• toDegrees() method is available in java.lang package.
• toDegrees() method is used to convert the given angle from radians to degrees or in other words, this method is used to convert an angle measured in radians to an equivalent angle measured in degrees.
• toDegrees() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get any error.
• toDegrees() method does not throw any exception at the time of conversion of angle from radians to degrees.
• The result of conversion an angle from radians to degrees is not generally exact.

Syntax:

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

Parameter(s):

Return value:

The return type of this method is double – it returns the degrees converted value of the given angle (in radians).

Example:

```// Java program to demonstrate the example of
// toDegrees(double ang_in_rad) method of StrictMath class

public class ToDegrees {
public static void main(String[] args) {
// Variable Declarations
double d1 = 60;
double d2 = -60;
double d3 = 90;
double d4 = -90;

// Display previous value of d1,d2,d3 and d4
System.out.println("d1: " + d1);
System.out.println("d2: " + d2);
System.out.println("d3: " + d3);
System.out.println("d4: " + d4);

// By using toDegrees() method is used to convert the
//given angle from radians into degrees

d1 = StrictMath.toDegrees(d1);
d2 = StrictMath.toDegrees(d2);
d3 = StrictMath.toDegrees(d3);
d4 = StrictMath.toDegrees(d4);

System.out.println("StrictMath.toDegrees(d1): " + d1);
System.out.println("StrictMath.toDegrees(d2): " + d2);
System.out.println("StrictMath.toDegrees(d3): " + d3);
System.out.println("StrictMath.toDegrees(d4): " + d4);
}
}
```

Output

```d1: 60.0
d2: -60.0
d3: 90.0
d4: -90.0
StrictMath.toDegrees(d1): 3437.746770784939
StrictMath.toDegrees(d2): -3437.746770784939
StrictMath.toDegrees(d3): 5156.620156177409
StrictMath.toDegrees(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