Java cbrt Function

The Java cbrt Function is one of the Java Math Library function and it is used to find the cube root of a specified expression or an individual double value. In this article we will show you, How to write Math.cbrt function in Java Programming language with example.

Java cbrt Function syntax

The basic syntax of the Math.cbrt in Java Programming language is as shown below. Following function will accept positive double value as argument and returns the cube root of the specified expression or Value.

static double cbrt(double number); //Return Type is Double
// In order to use in program:
Math.cbrt(double number);

Number: It can be a double value or a valid numerical expression for which you want to find the cube root.

If the number argument is positive or negative double value, Math.cbrt function will return the cube root of a given value.

If the number argument is not a number (NaN), java Math.cbrt function will return NaN.

If the number argument is infinity, Math.cbrt function will return the result as Infinity with same sign.

Java cbrt Function Example

The Java Math.cbrt Function allows you to find the cube root of a specified expression or an individual double value. In this Java program, We are going to find the same and display the output.

Next, We used the Java For Loop to iterate the Array. Within the For Loop, we initialized the i value as 0. Next, compiler will check the condition (i < cbrtArray.length). As along the condition is True statement inside the for loop will be executed.

TIP: cbrtArray.length is used to find the length of an array.

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

Following statements will print the output. If you observe the code snippet, we used the Math.cbrt Function directly inside the System.out.format statement. Here, compiler will call the Java Math.cbrt method ( static double cbrt(double number) ) to find the cube root of corresponding values.