Source of FormatterTest.java


  1: // Fig. 28.24: FormatterTest.java
  2: // Format string with class Formatter.
  3: import java.util.Formatter;
  4: import javax.swing.JOptionPane;
  5: 
  6: public class FormatterTest 
  7: {
  8:    public static void main( String args[] ) 
  9:    {
 10:       // create Formatter and format output
 11:       Formatter formatter = new Formatter();
 12:       formatter.format( "%d = %#o = %#X", 10, 10, 10 );
 13: 
 14:       // display output in JOptionPane
 15:       JOptionPane.showMessageDialog( null, formatter.toString() );
 16:    } // end main
 17: } // end class FormatterTest
 18: 
 19: /**************************************************************************
 20:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 21:  * Pearson Education, Inc. All Rights Reserved.                           *
 22:  *                                                                        *
 23:  * DISCLAIMER: The authors and publisher of this book have used their     *
 24:  * best efforts in preparing the book. These efforts include the          *
 25:  * development, research, and testing of the theories and programs        *
 26:  * to determine their effectiveness. The authors and publisher make       *
 27:  * no warranty of any kind, expressed or implied, with regard to these    *
 28:  * programs or to the documentation contained in these books. The authors *
 29:  * and publisher shall not be liable in any event for incidental or       *
 30:  * consequential damages in connection with, or arising out of, the       *
 31:  * furnishing, performance, or use of these programs.                     *
 32:  *************************************************************************/