Consider
Double f = 2.0;
String s = f.toString();
The resulting string s is "2.0". How can I format f so the answer for the case where f doesn't have a decimal part doesn't have the .0 appended? (For cases where f has a decimal part, I need that to be included.). Yes, for some reason, the toString() method on a Double appends .0 for the case where the Double is an integer.
A nasty hack would be
f % 1.0 == 0.0 ? new Integer(f.intValue()).toString() : f.toString();
but to me that looks terrible.