| Author |
Getting 01 output versus 1
|
Mark Adams
Greenhorn
Joined: Nov 23, 2007
Posts: 16
|
posted

0
|
Can anyone please tell me how I can get a double digit output of 01 rather than just 1. I have an output that looks like this: 1,22,2,45,6 and would like it to look like this: 01,22,02,45,06 I know it someting very silly and can't wait to see the response. Thank you, Mark
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12953
|
|
There are several ways to do this.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
|
|
. . . and what about System.out.printf("%02d", number); Even shorter!
|
 |
 |
|
|
subject: Getting 01 output versus 1
|
|
|