

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java toDegrees() method with Examples
The java.lang.Math.toDegrees(double angrad) converts an angle measured in radians to an approximately equivalent angle measured in degrees. The conversion from radians to degrees is generally inexact; users should not expect cos(toRadians(90.0)) to exactly equal 0.0.
Here, the argument angrad is in radians.
Example
Following is an example to implement toDegrees() method in Java −
import java.lang.*; public class Demo { public static void main(String[] args) { double x = 45; double y = -180; x = Math.toDegrees(x); y = Math.toDegrees(y); System.out.println("Math.tanh(" + x + ")=" + Math.tanh(x)); System.out.println("Math.tanh(" + y + ")=" + Math.tanh(y)); } }
Output
Math.tanh(2578.3100780887044)=1.0 Math.tanh(-10313.240312354817)=-1.0
Example
Let us see another example −
import java.lang.*; public class Demo { public static void main(String[] args) { double x; x = Math.PI; System.out.println(Math.toDegrees(x)); } }
Output
180.0
- Related Questions & Answers
- Java signum() method with Examples
- Java lang.Long.toBinaryString() method with Examples
- Java cbrt() method with Examples
- Java ceil() method with Examples
- Java sqrt() method with Examples
- Java floor() method with Examples
- Java streams counting() method with examples
- Java Signature getAlgorithm() method with Examples
- Java Signature getInstance() method with Examples
- Java Signature getProvider() method with Examples
- Java Signature initSign() method with Examples
- Java Signature toString() method with Examples
- Java lang Integer.toHexString() Method with Examples
- Java lang Long.toOctalString() Method with Examples
- Matcher start() method in Java with Examples
Advertisements