Is this correct? I wrote a decimal format and it doesn't work. how do i correct this:

    return sum / myFormatter.format(Math.sqrt(x.length - 1));

I will submit the full code if needed.

Edited by <M/>

Votes + Comments
is already being discussed in OPs earlier thread
4 Years
Discussion Span
Last Post by dev90

OK, I'll assume that the myFormatter variable holds an instance of the DecimalFormat class. And that the sum variable is some kind of number -- like a int or double or something similar.

So the line you gave above doesn't compile -- because the result of the ".format(...)" method is a String value, and you can't do math (like the division ('/') operator) on String values.

Maybe this is what you want...?

return myFormatter.format(sum / Math.sqrt(x.length - 1));
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.