Printing with the 0 (zero) flag fills in leading zeros. - Java Language Basics

Java examples for Language Basics:Number Format

Description

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

Demo Code

public class Main 
{
   public static void main(String[] args)
   { /*from w ww .  j  a  v  a2  s. com*/
      System.out.printf("%+09d\n", 452);
      System.out.printf("%09d\n", 452);
      System.out.printf("% 9d\n", 452);
   } 
}

Result


Related Tutorials