I have double values in Java like the following:
2.3422
45.3267
25.0
What I want to print is:
2.34
45.32
25
So I used the following method
DecimalFormat form=new DecimalFormat("#0.00");
form.format(value);
But the problem I am facing is for 25.0 it is printing 25.0 But I want to print 25 only what do i do?
Please note that casting the double value to integer would work for 25.0 but then it would fail for values like 2.3422.