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