I'm glad you've got it sorted out. Don't forget to let them know at DevShed.
The "%d" business is used with the String format() method and with the printf() of PrintStream and elsewhere. It is documented as part of the
Formatter class.
The first thing to do with that documentation is not to panic! You aren't expected to commit it to memory or even understand it in complete detail. Rather you remember where it is and consult it as needed: learning some new "trick" each time.
Maybe the following will be suggestive.
public class FormatExamples {
public static void main(String[] args) {
String[] strings = {"the", "quick", "brown", "fox"};
int[] integers = {0, -1, 666, 42};
// (1)
for(int ndx = 0; ndx < strings.length; ndx++) {
System.out.printf("%s: %d%n", strings[ndx], integers[ndx]);
}
// (2)
for(int ndx = 0; ndx < strings.length; ndx++) {
System.out.printf("%5s%8d%n", strings[ndx], integers[ndx]);
}
// (3)
for(int ndx = 0; ndx < strings.length; ndx++) {
System.out.printf("%-5s%8d%n", strings[ndx], integers[ndx]);
}
// (4)
for(int ndx = 0; ndx < strings.length; ndx++) {
System.out.printf("%-5s%8d%10.3f%n", strings[ndx], integers[ndx], integers[ndx] * Math.PI);
}
}
}
(1) %s means "interpret the argument as a
string" and %d means "interpret the argument as a
decimal integer". %n means "
newline" (argument not necessary) and will do the right thing on Windows and *nix (traditional and iHaveToBeDifferent). Other stuff - the colon and the space for example - is printed as is.
(2) A number after the % means "width". Note that this makes use of tabs redundant. Setting the width is actually more reliable than using a \t character which can do different things in different circumstances.
(3) A negative sign before the number means "left align": things are right aligned by default.
(4) Finally a number like 10.3 means "10 wide including three digits after the decimal point". It is used for f==
floating point arguments. The 3 is called "precision" and rounding is done for you.
-----
Much the same syntax is used in other languages (C, PHP, etc) so it's worth getting used to.