Mega Code Archive

 
Categories / Java Tutorial / Development
 

Printing with the 0 (zero) flag fills in leading zeros

public class MainClass  {    public static void main( String args[] )    {        System.out.printf( "%+09d\n", 452 );       System.out.printf( "%09d\n", 452 );       System.out.printf( "% 9d\n", 452 );    } } +00000452 000000452 452