×

Java Math toDegrees() Method

The toDegrees() method of Java Math class converts a radian angle to an approximately equivalent angle measured in degrees.

Syntax:

public static double toDegrees(double angrad)

Parameters:

The parameter ‘angrad ‘represents an angle measured in radians.

Return Value:

The toDegrees () method returns the angrad’s measurement in degrees.

Example 1:

public class JavaMathToDegreesExample1 {
    public static void main(String[] args) {
        double a=10.780;
        //converts a radian angle to an approximately equivalent angle measured in degrees
        System.out.println("Radian Angle "+ a+" converted in degrees = "+Math.toDegrees(a));
    }
}

Output:

Radian Angle 10.78 converted in degrees = 617.6485031510274

Example 2:

public class JavaMathToDegreesExample2 {
    public static void main(String[] args) {
        double a=Double.MIN_VALUE;
        //converts a radian angle to an approximately equivalent angle measured in degrees
        System.out.println("Radian Angle "+ a+" converted in degrees = "+Math.toDegrees(a));
    }
}

Output:

Radian Angle 4.9E-324 converted in degrees = 2.8E-322

Example 3:

public class JavaMathToDegreesExample3 {
    public static void main(String[] args) {
        double a=Double.NaN;
        //converts a radian angle to an approximately equivalent angle measured in degrees
        System.out.println("Radian Angle "+ a+" converted in degrees = "+Math.toDegrees(a));
    }
}

Output:

Radian Angle NaN converted in degrees = NaN

Example 4:

public class JavaMathToDegreesExample4 {
    public static void main(String[] args) {
        double a=Double.NEGATIVE_INFINITY;
        //converts a radian angle to an approximately equivalent angle measured in degrees
        System.out.println("Radian Angle "+ a+" converted in degrees = "+Math.toDegrees(a));
    }
}

Output:

Radian Angle -Infinity converted in degrees = -Infinity

Example 5:

public class JavaMathToDegreesExample5 {
    public static void main(String[] args) {
        double a=-0d;
        //converts a radian angle to an approximately equivalent angle measured in degrees
        System.out.println("Radian Angle "+ a+" converted in degrees = "+Math.toDegrees(a));
    }
}

Output:

Radian Angle -0.0 converted in degrees = -0.0

Related Topics

Gregorian Calendar Java Current Date

GregorianCalendar class uses the Gregorian and Julian calendars. Dates are calculated by projecting present laws forever backward and forward in time. As a consequence, GregorianCalendar may be utilised to create...

8 minutes read.

Java throws

Java throws: The Java throws keyword is used with the signature of the method to indicate that the method may raise an exception. The method that uses the Java throws...

3 minutes read.

Fork Join in Java

Multithreaded processors are being introduced in new computer systems today. The operation is faster due to multicore CPUs. Therefore, it becomes essential for a programmer to leverage multithreaded processors effectively...

4 minutes read.

Timestamp Operation in Java

JDBC escape syntax is supported by Timestamp's formatting and parsing functions. Additionally, it adds support for fractional seconds values for SQL TIMESTAMP.java.util.Date is wrapped in a lightweight wrapper that enables...

3 minutes read.

How to Solve the Deprecated Error in Java?

Deprecated Java methods should not be used because they are deprecated (often, there are better, more modern alternatives). API update. Until now, Java has kept everything backward compatible and never...

3 minutes read.

JDBC vs ODBC

Difference Between JDBC and ODBC ODBC: ODBC (Open Database Connectivity) is the accepted method for accessing databases among organisations and programmers. A database is linked to other programmes, such as word processors, spreadsheets,...

4 minutes read.

Java Beans

It is a Java class, It follows conventions they are: It must have a no-arg constructorIt must be serializable.It must provide the methods to get and set the properties Uses Of Java...

3 minutes read.

Inheritance Program in Java

Inheritance Program in Java Inheritance is one of the important pillars of Object-Oriented Programming that facilitates parent-child relationships in programming. Using inheritance, we can create a new class with the help...

7 minutes read.

How to Assign Static Value to Date in Java?

In this tutorial, we will learn certain ways to assign a static value to a date in java. We will see the limitation of each method that will lead to...

3 minutes read.

Why to use Enum in Java?

In this article, you will be acknowledged about the Enum in java, its uses and mainly its purpose. Enum has various functionalities. Each of them will be discussed. Enum In a computer...

3 minutes read.

Sales Tax Problem in Java

To calculate the sales tax on a purchase in Java, you will need to know the following information: The cost of the item being purchased The sales tax rate You can then use...

4 minutes read.

Trimorphic numbers in Java

Wondered what the Trimorphic number is!! In this article, you can learn about what a Trimorphic number is referred to as and how to find whether a number is trimorphic...

3 minutes read.

Java LinkedList vs ArrayList

LinkedList In LinkedList, each element is a distinct entity containing an information portion and an address component, and the elements are not kept in consecutive locations. Pointers & addresses are used...

3 minutes read.

Java Math toRadians() Method

The toRadians() method of Java Math class converts an angle measured in degrees to an approximately equivalent angle measured in radian. Syntax: public static double toRadians (double angdeg) Parameters The parameter ‘angdeg’ represents an...

2 minutes read.

Special Operators in Java

An operator in Java is a special symbol. It is used to perform operations on two or more variables.  We all know basic operations in Java. There are 8 types...

5 minutes read.

Compile-time Error in Java

In java, the execution of a program is stopped due to the occurrence of some problem known as an error. Errors are illegal operations that are carried out by the...

4 minutes read.

Java Swing

Java Swing is the extension of Abstract Windows Toolkit (AWT). Any component designed in Swing will appear the same on any platform. Problems/Disadvantage of Abstract Windows Toolkit (AWT): As we know that...

27 minutes read.

How to Convert char to int in Java

How to Convert char to int in Java When two variables of different types are involved in the single expression, Java compiler uses built-in library function to convert the variable to...

3 minutes read.

Classes and Objects in Java Example Programs

Classes and Objects in Java Example Programs Java is an Object-Oriented programming language, i.e., everything in Java is associated with objects and objects are associated with classes. The classes and objects...

5 minutes read.

Java Pop

The array, linked list, stack, queue, and other data structures are supported by Java programming. The insertion, deletion, and element searching operations are available for every data structure. And Java...

4 minutes read.