## Description :

This java tutorial shows an example on how to use the toDegrees(double angrad) method of Math class under java.lang package. This method returns the equivalent in degrees the value specified angle in degrees as method argument.

## Method Syntax :

public static double toDegrees(double angrad)

## Parameter Input :

DataType Parameter Description
double angrad the angle in radians to be converted in degrees

## Method Returns :

The toDegrees(double angrad) method simply returns the equivalent in degreess the radians specified as method argument.

## Compatibility Version :

Requires Java 1.0 and up

N/A

## Discussion :

The toDegrees(double angrad) method is static thus we should invoke it statically for example Math.toDegrees(double angrad). This method simply returns the equivalent in degrees the angle in radians as method argument. We would be using this widely since the trigonometric functions of Math class usually takes radians as an input which is very much different in real life applications since angles is usually represented in degrees.

## Java Code Example :

This java example source code demonstrates the use of toDegrees method of Math class. Basically we just convert the angle in radians from user input into degrees.

```package com.javatutorialhq.java.examples;

import static java.lang.System.*;

import java.util.Scanner;

/*
* This example source code demonstrates the use of
* toDegrees(double angrad) method of Math class
*/

public class MathToDegrees {

public static void main(String[] args) {
// ask for user input
out.print("Enter angle in radians:");
Scanner scan = new Scanner(System.in);
// use scanner to get user console input
double radians = scan.nextDouble();
// convert the angle from radians to degrees
double degrees = Math.toDegrees(radians);
out.println(radians +" radians = "+degrees +" degrees");
// close the scanner object to avoid memory leak
scan.close();

}

}```

## Sample Output :

Running the toDegrees(double angrad) method example source code of Math class will give you the following output

```Enter angle in radians:2.09
2.09 radians = 119.74817918234206 degrees```

N/A

• N/A