×

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

Difference between Aggregation and Composition in Java

What is Aggregation? Before we start discussing Aggregation, we have to know some general information about our classes in java. Generally we have two members in our classes , the first...

8 minutes read.

Java Command Line Arguments

Java command line arguments Command line argument is an input or argument to the program when you run the program. In Java, we can take the inputs from the console, and...

2 minutes read.

Multiple Inheritance Programs in Java

A component of the object-oriented notion known as multiple inheritances allows a class to inherit properties from multiple parent classes. When methods that have the same signature are present in...

4 minutes read.

Java Integer compare() method

The compare() method of Integer class compares the two specified int values. Syntax public static int compare(int x, int y) Parameters The parameters ‘x’ and ‘y’ represent the first and second int values to...

2 minutes read.

Java Substring

What is a substring in Java? Here by the name  " substring " itself, we can easily come to know it is a part of a string or a subset of...

4 minutes read.

Java File

Java file class implements the concept of file handling. It has several methods, such as deleting, creating, reading, and updating files. This class allows java users to perform various operations...

5 minutes read.

Java String equals() method

equals() method compares two string based on the their content. Syntax public boolean equals(Objects anObject) parameter anObject: Object to be compared with the current String. Returns It returns true when the current String is equivalent to...

1 minute read.

Java String format() method

format() method returns a formatted String based on the given locale,specified format and arguments. Syntax: public static String format(String format , Object… args) Parameter: locale : It specifies locale value to be applied on...

2 minutes read.

Java Lambda foreach

Before understanding lamda foreach, one must know about foreach loop in Java. foreach loop in Java Since J2SE 5.0, there has been a for-each loop in Java, also known as an extended...

4 minutes read.

How to add 24 Hours to Date in Java?

In this tutorial, we will learn how to add 24 hours to the local or current date in Java language. We will begin our topic with basic concepts and would...

2 minutes read.

Types of Bitwise Operators in Java

In this tutorial, we will learn about the various types or kinds of bitwise operators in java. Before proceeding to bitwise operators, let us know what is meant by the...

6 minutes read.

Memory Areas in Java

Let’s have a look at how memory management in Java works. We will be going to discuss how the objects get destroyed, the working of a garbage collector, and things...

5 minutes read.

How to Convert int to long in Java

How to Convert int to long 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...

2 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.

Cast Operator in Java

A cast is a unique operator that completely converts one type of data into another. Casts are unary operators and have the same priority as other unary operators. Type casting in...

3 minutes read.

Java 13 New Features

The Java SE Platform's JDK 13 version is an open-source reference implementation defined by the Java Community's JSR 388 Process. The necessary modifications made in Java 13 are listed below....

6 minutes read.

Matrix Multiplication Program in Java

Matrix Multiplication Program in Java The matrix multiplication program in Java is the continuation of the matrix program in Java that we have already discussed earlier. In this section, we will...

3 minutes read.

How to Reduce Time Complexity in Java

What is time complexity?  The time complexity in java is given as the amount of time a program requires to run or execute it Calculating the time complexity of the program The time...

4 minutes read.

Java copy constructor Example

Java provides the copy constructor much like C++ does. However, it is produced by default in C++. While we define our own copy constructor in Java. With an example, we will...

3 minutes read.

Intersection Point of two linked list in Java

In this article, you will be very well acknowledged about how to achieve the intersection point of two linked list in Java. There are several approaches to obtain. Surely each...

8 minutes read.