- //Right Padding With Zero at the start of the Number
- import java.util.*;
- import java.lang.*;
- class LeftpadWithZero
- {
- public static void main(String[] argv) {
- System.out.println(">" + padLeft(22, 10) + "<" );
- }
- public static String padLeft(int s, int n) {
- return String.format("%0"+n+"d", s);
- }
- }
Output: |
---|
>0000000022< |