Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > JAVA TUTORIALS > TAMING TIGER: FORMATTED OUTPUT


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

Taming Tiger: Formatted output
By John Zukowski - 2004-05-03 Page:  1 2 3 4 5

Let there be printf

Tiger brings printf-style formatted output to the world of Java programming; and this month, columnist John Zukowski discusses all facets of the C-inspired support for printf and format strings.

The original plan for the 1.4 release J2SE included support for formatted output. Probably due to time constraints and the fact that the feature wasn't a release driver, the capabilities were left out of the release. Now with Tiger, there is built in support for printing with format strings.

For those who grew up with Java programming and never touched C or those who haven't lived in a C world for some time, format strings are those funky text strings that specify output characteristics for a bunch of variables. Instead of just concatenating strings together with the plus sign (as in firstName + " " + lastName), you provide a single string to describe the output and provide the arguments to fill the placeholders in that string at the end of the method call: String s = String.format("%1$s %2$s", firstName, lastName).



View Taming Tiger: Formatted output Discussion

Page:  1 2 3 4 5 Next Page: Formatter class

First published by IBM developerWorks


Copyright 2004-2024 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.