
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
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 Articles
- 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 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
- Java streams counting() method with examples
- MatchResult start() method in Java with examples.

Advertisements