It is particularly useful for making listings line up by assigning fixed widths to your fields or for displaying in hex.
G format gives you an ability like the G format in FØRTRAN, which will display in F format or E format as appropriate.
The java.text.DecimalFormat and java.text. NumberFormat classes in Java version 1.1 or later give you similar ability a bit more verbosely. Java 1.0.2 has no equivalent to the C printf or sprintf function for formatting numbers for display. You have to roll your own. One such class is available from San Diego State University called sdsu.FormatString. Acme also has one. Eliote Rusty Harold did one. Gary Cornell and Cay Horstmann’s book Core Java 2 includes one.Most people don’t bother with printf. They use the + concatenation operator instead of printf.
// in idiomatic Java you would say: out.println( "x:" + x + " y:" + y ); // instead of C-style out.printf( "x: %d y: %d", x, y );
recommend book⇒Core Java Volume I-Fundamentals (10th Edition) (Core Series) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
by | Cay S. Horstmann | 978-0-13-417730-4 | paperback | |||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
birth | 1959-06-16 age:58 | 978-0-13-417735-9 | eBook | |||||||||||||||||||||||||||||||||||||||||||||||||||||
publisher | Prentice Hall | B019PFBM0M | kindle | |||||||||||||||||||||||||||||||||||||||||||||||||||||
published | 2016-01-01 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
Aimed at someone who already knows C++. This is not a fluffy introductory book. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Greyed out stores probably do not have the item in stock. Try looking for it with a bookfinder. |
This page is posted |
http://mindprod.com/jgloss/printf.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\printf.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.144.100.138] |
| |
Feedback |
You are visitor number | |