×

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

Polygonal Number in Java

What does a Java Polygonal Number Mean? In mathematics, a polygonal number refers to a number that is expressed through dots or pebbles arranged in a regular polygonal pattern. Alphas are...

4 minutes read.

Constructor in Java with Example

Java Constructor  The constructor is used for object initialization. It's a block of code that initializes a newly created object. It contains a collection of statements that are executed at the...

5 minutes read.

Pig Latin Program in Java

Pig Latin Program in Java Pig Latin is a method for translating words of the English language into a different language. It is an encrypted word that is generated by using the following steps....

4 minutes read.

Program to Implement FLAMES Game in Java

Friends, Lovers, Affectionate, Marriage, Enemies, and Sibling are all represented by the acronym FLAMES, which also serves as the name of a well-known game. Although, it can be entertaining to...

4 minutes read.

How to use Lambda Expression in Java?

The new and significant lambda expression feature of Java was added in Java SE 8. It provides a clear and concise mechanism for describing a single method interface using an...

4 minutes read.

Java ResultSetMetaData

The data about another data is called Metadata. The ResultSetMetaData is used to store the data about ResultSet. The ResultSet Contains the columns, rows, names of table, datatypes etc. these...

2 minutes read.

Parallel Arrays Sort in Java

Sorting is a technique of arranging a sequence of numbers in ascending order, that is, the first number being lowest and gradually incrementing the numbers such that the last number...

7 minutes read.

Java Array Generic

Creating Generic Array in Java A collection of comparable sorts of data is kept in an array. In Java, making a generic array is challenging. The type information of an array's...

4 minutes read.

How to encrypt password in Java

Every software program needs a username and password to identify a legitimate user. A username can be any number of things, including an email address or a string of characters....

6 minutes read.

Minimum Number of Platforms Required for a Railway Station

The train station problem is one of the most significant problems typically posed in the programming round interview to gauge a candidate's aptitude for logic and problem-solving. Problem of Railway Station The...

6 minutes read.

Bubble Sort in Java

Bubble Sort in Java Bubble sort isalso known as sinking sort. It is one of the simplest sorting algorithms. In the bubble sort algorithm, the given array is traversed from left...

5 minutes read.

Java Append Data to File

When writing data to a file using the classes within the java.io package, its file will often be overwritten, meaning that any existing data will be removed and new data...

4 minutes read.

Types of Garbage Collector in Java

Garbage collection is a Java feature that offers automatic memory management. The JVM is in charge of it. The programmer does not have to handle object creation and deallocation. We...

3 minutes read.

Convert Char array to string in java

A collection of characters is referred to as a string. A character array differs from a string in that the string is canceled by the special character "\0." A string...

4 minutes read.

Java Plot

Java Plot is a phrase in Java that is mostly used for plotting coordinates on a cartesian plane. Plotting graphs in Java is accomplished through the use of various core...

3 minutes read.

Dutch National Flag Problem in Java

Dutch National Flag (DNF) is a programming issue that Edsger Dijkstra put up. The white, red, and blue hues make up the Dutch flag. The goal is to haphazardly set...

6 minutes read.

How to Compare Two Strings in Java

How to Compare Two Strings in Java On the basis of reference or content, one can compare two strings in Java. String comparison is used in reference matching (== operator), sorting...

4 minutes read.

What is Core Java?

The fundamental Java, which includes the fundamental idea of the Java programming language, is referred to as "Core Java." The definition of "Core" is the core idea of something. Core...

3 minutes read.

Java Switch string

A multi-way branch statement is the switch statement. It offers a simple method for allocating execution to various code sections according to the expression's value. Primitive data types, including bytes,...

3 minutes read.

Display List of TimeZone with GMT and UTC in Java

It is vital to establish the right TimeZone in Java code when working with dates for Daylight Saving Time. In this part, we will present the time zones with GMT. TimeZone Those...

5 minutes read.