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|
|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
Optional Replicator mirror
Your face IP:[22.214.171.124]
You are visitor number|