F.johansson F.johansson - 7 months ago 51
Java Question

.substring() is not working

I'm working on a square root function in Java and I need it to take the number beginning on character 5, ending on the second last one. It currently displays "sqrt([NUMBER])". I've tried to use substring but it doesn't work. I've put my code below.

a = Math.sqrt( Double.parseDouble(t.getText().substring( 4, t.getText().length() - 1)));

Tim Tim

String s = "sqrt(1.234)"; System.out.println(s.substring(5, s.length()-1));