debraj mallick wrote:i can not use this code to display because it returns string
What do you mean? If you want to display a number, it must be converted to a string somehow. There's no way around that. The question is how you get the string formatted the way you want.
If you want it with 4 decimal places, then specify that in your DecimalFormat:
An alternative is:
Is there a reason why you are using Double (the wrapper class) instead of double (the primitive type)? If not, then prefer double instead of Double.