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.

JamesCherrill commented: is already being discussed in OPs earlier thread -3

Recommended Answers

All 2 Replies

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));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.