Mega Code Archive

 
Categories / Java Tutorial / Development
 

Using Javas printf( ) Method

The printf( ) method automatically uses Formatter to create a formatted string. The printf( ) method is defined by both PrintStream and PrintWriter. For PrintStream, printf( ) has these forms: PrintStream printf(String fmtString, Object ... args) PrintStream printf(Local loc, String fmtString, Object ... args) The first version writes args to standard output in the format specified by fmtString, using the default locale. The second lets you specify a locale.