I have an int between 1 - 99. How do I get it to always be a double digit, ie: 01, 04, 21?
I think, I should add the link to the official Java documentation on formatting numeric outputs.
https://docs.oracle.com/javase/tutorial/java/data/numberformat.html
Sample Snipplet: Prints 00 up to 100
class Main {
public static void main(String[] args) {
for(int i=0;i<=100;i++){
System.out.println(String.format("%02d", i));
}
}
}
Output:
00
01
...
10
...
100