Mega Code Archive

 
Categories / Java Tutorial / Development
 

The 0 flag

The 0 flag causes output to be padded with zeros rather than spaces. The 0 flag can be used with all format specifiers except %n. import java.util.Formatter; public class MainClass {   public static void main(String args[]) {     Formatter fmt = new Formatter();     fmt.format("%05d", 100);     System.out.println(fmt);   } } 00100