Convert 1 to 01

前端 未结 11 1468
逝去的感伤
逝去的感伤 2021-02-07 04:09

I have an int between 1 - 99. How do I get it to always be a double digit, ie: 01, 04, 21?

11条回答
  •  野的像风
    2021-02-07 05:09

    Or you could just use printf instead of String.format

     for (int i = 0; i <= 100; i++) {
             System.out.printf("%02d%n",i);
        }
    

提交回复
热议问题