In mathematics, the **cube root** of a number refers to another number, which, multiplied thrice by itself, produces that number.

The cube root of the number 27 is 3. We can see how in the example below.

Cube root example

We use the ** Math.cbrt() method** in Java to find the cube root of a given number.

The implementation header of `Math.cbrt()`

function in Java is given below:

```
public static double cbrt(double x)
```

To call this function, we use the following syntax:

```
double cuberoot = Math.cbrt(27)
```

The `cbrt()`

function takes a double value, whose cube root is to be determined, as a parameter.
It also returns the cube root as a double value.

The example below demonstrates the use of the `Math.cbrt`

function to find the cube roots of several numbers.

class CubeRoot{public static void main( String args[] ) {// calculate the cube root of 27System.out.println( "Cube Root of 27 is: "+ Math.cbrt(27) );// calculate the cube root of 8System.out.println( "Cube Root of 8 is: "+ Math.cbrt(8) );// calculate the cube root of 64System.out.println( "Cube Root of 64 is: "+ Math.cbrt(64) );}}

- Line 4: We calculate the cube root of
`27`

and display the results using`System.out.println`

. - Line 6: We calculate the cube root of
`8`

and display the results using`System.out.println`

. - Line 8: We calculate the cube root of
`64`

and display the results using`System.out.println`

.

Copyright ©2024 Educative, Inc. All rights reserved

TRENDING TOPICS