System.out.printf("The temperature is %.2fC or %.2fF.%n", celsius, fahrenheit);
That will print "The temperature is 20.00C or 68.00F.", assuming you haven't got a rounding error producing 67.99F or similar!
Joined: Nov 26, 2008
OH... so I don't need to specify strings at all. The % acts kind of like an escape character?
I had read the tutorial but did not see how to specify a string in addition to numbers. Your post was very helpful
Thanks Campbell!! - jeff
Joined: Oct 13, 2005
You're welcome. You can print a String variable with the %s tags. For entertainment purposes: try the %s tag with a variety of different Objects and see what happens. Then try the %b tag with a variety of different Objects and numbers and see what happens. Be sure to try some "null" references amongst the Objects.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com