You can do it with System.out.printf(). It's a little obscure, but I'll walk you through it.
System.out.printf(<format_string>, arg1 [, arg2 ...]);
The format
string has "markers" in it that tell where to place the arguments. The markers start with a "%", then a conversion character. "d" is for digit, "f" is for floating point, and "s" is for string. There are others, but those will get you far.
In between the "%" and the conversion character can go flags, width, and a precision. We need a flag of "0" to signify zero-filled and a width of 2. Pulling it all together, we have:
System.out.printf("%02d | ", digit);
Fiddle around with it a see how that works. To read more about the format, click
here.