最佳答案
I was working with numbers recently and I had a situation where I want to set the precision of a double value say to 6 digits or 4 digits, depending on the value stored in the database.
For example, If in the database the precision is set as 4 digits then the output must look as,
10.0000.
I tried with DecimalFormat and using the string ##.####, but it is annoying to use symbols everytime.
Is there any better approach, say something like below:
Double value = 10.0;
value.setPrecision(4);