java int format numbers code example
Example 1: formatting an integer in java
Default formatting:
String.format("%d", 93);
Specifying a width:
String.format("|%20d|", 93);
Left-justifying within the specified width:
String.format("|%-20d|", 93);
Pad with zeros:
String.format("|%020d|", 93);
Example 2: formatting an integer in java
Specifying a width:
String.format("|%20d|", 93);
Left-justifying within the specified width:
String.format("|%-20d|", 93);
Pad with zeros:
String.format("|%020d|", 93);