Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java printf leading zeros

public class Main {
    public static void main(String[] args) {
        int number = 2;
        System.out.println(String.format("%04d", number));
        // 0 - declares padding between the zeroes
        // 4 - declares the width of the string
    }
}
 
PREVIOUS NEXT
Tagged: #java #printf #leading #zeros
ADD COMMENT
Topic
Name
8+5 =