F.johansson F.johansson - 1 year ago 89
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
Answer Source

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



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download