F.johansson - 9 months ago 58

Java Question

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)));`

Answer Source

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

returns

`1.234`