To calculate the cube root and the square root of a `double`

value we can use the `Math.cbrt(double a)`

and `Math.sqrt(double a)`

static method call.

package org.kodejava.example.math; public class CubeSquareRootExample { public static void main(String[] args) { double cube = 125.0d; double square = 100.0d; // // Get the cube root of double value // double cbrt = Math.cbrt(cube); System.out.println("Cube root of " + cube + " is " + cbrt); // // Get the square root of double value // double sqrt = Math.sqrt(square); System.out.println("Square root of " + square + " is " + sqrt); } }

This snippet will print the following output:

Cube root of 125.0 is 5.0 Square root of 100.0 is 10.0

### Wayan Saryada

Programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, Hibernate / JPA.

#### Latest posts by Wayan Saryada (see all)

- How to format LocalDate object using Jackson? - February 16, 2017
- How to pretty print JSON string using Jackson? - February 15, 2017
- How to convert java.time.LocalDate to java.util.Date? - February 14, 2017