The Java toRadians Function is one of the Java Math Library functions, which is to converts an angle measured in degrees to an approximately equivalent angle measured in radians. In this article, we will show how to use Java Math.toRadians function with example. The syntax of the Math.toRadians in Java Programming language is

```static double toRadians(double number); //Return Type is Double

// To use in program:

Number: It can be an angle in degree for which you want to convert as a radian

The Math.toRadians Function allows to converts degrees to an approximately equivalent angle measured in radians. In this toRadians Java program, We are going to find the radians of both positive and negative values and display the output

```// Java Math.toRadians Function

package TrigonometricFunctions;

public static void main(String[] args) {
double x = Math.toRadians(400.96 + 240.65 - 106.98);
System.out.println("toRadians Function result =  " + x);

}
}```

First, We declared variable x of type Double and used the Java Math.toRadians function directly on expression. Here, we used System.out.println statement to print the radiant result as output.

```double x = Math.toRadians(400.96 + 240.65 - 106.98);
System.out.println("toRadians Function result =  " + x);```

Next, We used the Math.toRadians Function directly on Positive double values.

```System.out.println("\nFinding Radians of Positive Number = " + Math.toRadians(104.95));

Next, We used the toRadians Math function directly on Negative double values.

```System.out.println("\nFinding Radians of Negative Number =  " + Math.toRadians(-135.85));

## Java toRadians on Array example

In this Java program, we convert the bulk data to radians. Here, we are going to declare an Array of double type. Next, we use Java toRadians function to convert the array elements to radians.

```package TrigonometricFunctions;

public static void main(String[] args) {

double [] myArray = {1, 30, 45, 60, 75, 90, 120, 180, 240, 360};

for (int i = 0; i < myArray.length; i++) {
}
}
}```
``````Finding Radians of Array Element 1.00 is = 0.0175
Finding Radians of Array Element 30.00 is = 0.5236
Finding Radians of Array Element 45.00 is = 0.7854
Finding Radians of Array Element 60.00 is = 1.0472
Finding Radians of Array Element 75.00 is = 1.3090
Finding Radians of Array Element 90.00 is = 1.5708
Finding Radians of Array Element 120.00 is = 2.0944
Finding Radians of Array Element 180.00 is = 3.1416
Finding Radians of Array Element 240.00 is = 4.1888
Finding Radians of Array Element 360.00 is = 6.2832``````

We used the Java For Loop to iterate the Array. Within the toradians For Loop, we initialized the i value as 0. Next, compiler will check the condition (i < myArray.length).

TIP: myArray.length finds the length of an array.

`for (int i = 0; i < myArray.length; i++) {`

Here, we used the Math.toRadians Function directly inside the System.out.format statement. It means the compiler will call the Math.toRadians method ( static double toRadians(double number) ) to find the corresponding radiant values.

`System.out.format("Finding Radians of Array Element %.2f is = %.4f\n", myArray[i], Math.toRadians(myArray[i]));`

NOTE: To find the radiant value of a single item, then use: Math.toRadians(myArray[index_position])

## Java toRadians Function on Arraylist example

In this Java program, we are going to declare an Arraylist of double type and find the Radiant values of list elements.

```package TrigonometricFunctions;

import java.util.ArrayList;

public static void main(String[] args) {
ArrayList<Double> myList = new ArrayList<Double>(5);

for (double x : myList) {
}
}
}```
``````Finding Radians of ArrayList Item 3.14 =  0.0548
Finding Radians of ArrayList Item 1.05 =  0.0183
Finding Radians of ArrayList Item 0.79 =  0.0137
Finding Radians of ArrayList Item 0.52 =  0.0091
Finding Radians of ArrayList Item 0.35 =  0.0061 ``````

Within this toRadians function example, We declared an ArrayList of double type and assigned random values using Math.PI constant (its value is approximately 3.14).

```ArrayList<Double> myList = new ArrayList<Double>(5);
`for (double x : myList) {`
`System.out.format("Finding Radians of ArrayList Item %.2f =  %.4f \n", x, Math.toRadians(x));`