Formula to calculate square Root - Android java.lang

Android examples for java.lang:Math Formula

Description

Formula to calculate square Root

Demo Code


import java.text.DecimalFormat;

public class Main{
    public static double squareRoot(double value)
            throws InvalidInputException {
        if (value >= 0) {
            return Math.sqrt(value);
        } else {// w  w w . ja v  a  2s  .com
            throw new InvalidInputException();
        }
    }
}

Related Tutorials