×

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 angle measured in degrees.

Return Value:

The toRadians() method returns the an inexact angdeg measurement in radians.

Example 1:

public class JavaMathToRadiansExample1 {
    public static void main(String[] args) {
        double a=67;
        //converts a degree angle to an approximately equivalent angle measured in radian
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle 67.0 converted in radian = 1.1693705988362009

Example 2:

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

Output:

Degree Angle 4.9E-324 converted in radian = 0.0

Example 3:

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

Output:

Degree Angle -0.0 converted in radian = -0.0

Example 4:

public class JavaMathToRadiansExample4 {
    public static void main(String[] args) {
        double a=Double.NaN;
        //returns NaN, if the argument passed is NaN
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle NaN converted in radian = NaN

Example 5:

public class JavaMathToRadiansExample5 {
    public static void main(String[] args) {
        double a=Double.NEGATIVE_INFINITY;
        //returns negative -infinity, if the argument passed is negative infinity
        System.out.println("Degree Angle "+ a+" converted in radian = "+Math.toRadians(a));
    }
}

Output:

Degree Angle -Infinity converted in radian = -Infinity

Related Topics

this keyword in Java

The 'this' keyword is an essential notion in Java. We'll go through the 'this' keyword in depth and provide some examples of how it's used in Java. In Java, the term...

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

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.

How to Convert char to String in Java

How to Convert char to String in Java There are two methods to convert char to String: Using String.valueOf(char) method Using Charcter.toString(char) method Using String.valueOf(char) method valueOf(char) is the static method of String class that...

2 minutes read.

Convert JSON File to String in Java

Before understanding the conversion of JSON file to string, one must know about JSON. What is JSON? JSON stands for JavaScript Object Notation. It is an open standard format lightweight, text-based, and...

3 minutes read.

How to Round Double Float up to Two Decimal Places in Java

It indicates 15 digits just after the decimal place in Java whenever a double data type is used in front of a variable. For example, when representing rupees and other...

4 minutes read.

Stack Program in Java

Stack Program in Java The Stack class is part of the collection framework that inherits the Vector class. Thus, the Stack class can also be called a subclass of the Vector...

5 minutes read.

Java Math tan() Method

The tan() method of Java Math class returns the trigonometric tangent of the specified angle. Syntax: public static double tan(double a) Parameters: The parameter ‘a’ represents an angle measured in radians. Return Value: The tan() method...

2 minutes read.

Coin change problem in dynamic programming

In this tutorial, we will understand a popular problem called the coin changeproblem through dynamic programming. This problem checks the logical and critical thinking ability of the person. Dynamic Programming...

5 minutes read.

MVC in Java

A well-known design pattern is Model-View-Controller. The discipline of web development. We can organize our code in this manner. The document stipulates that a program or application must include a...

4 minutes read.

Java program to print matrix in Z form

In this article, you will be acknowledged about what is a matrix along with an example. Also, most importantly, you will learn how to print matrix in Z form. What is...

5 minutes read.

Unicode System in Java

In this tutorial, we will understand the meaning and emergence of the Unicode system in java. The Unicode system is one of the important and useful features in the world...

6 minutes read.

Java array list remove time complexity

Java: We know that java is one of the programming languages. The main feature of java which is not in C or object oriented programming language is platform independence. Not only the...

7 minutes read.

Java BufferedWriter

BufferWriter Class: It is used to write the data more efficiently. This class is present in the java.io package, it inherits the data from the Writer class. Writer class is...

4 minutes read.

Misc Operators in Java

In this article, we are going to learn about the misc operators in Java. Misc operators are nothing but the miscellaneous operators. The java programming language supports some of the...

4 minutes read.

Chromatic Number in Java

The chromatic number is the bare minimum of colours necessary to accurately colour any graph. To put it another way, the chromatic number can be thought of as the bare...

6 minutes read.

Knapsack problem in Java

We have a collection of items in the knapsack problem. Every object has a weight and a value. These things should go in a knapsack. But there is a weight...

3 minutes read.

How to Convert String to float in Java

How to Convert String to Float in java It is used if you want to perform mathematical operations on the string that contains float number. You can convert String to float...

3 minutes read.

Java Anon Proxy

The Java Anon Proxy (JAP), also known as JonDonym, is a proxy system designed to enable Web browsing with revocable (the use of or publication under a pseudonym, a false...

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