http://www.devdaily.com/blog/post/software-dev/cheat-sheet-reference-printf-format-specifier-syntax/
printf – a quick look at Perl and Java
In this cheat sheet I’m going to show all the examples using Perl, but I thought at first it might help to one printf example using both Perl and Java. So, here’s a simple Perl printf example to get us started:
printf(“the %s jumped over the %s, %d times”, “cow”, “moon”, 2);
And here are three different ways of using printf format specifier syntax with Java:
System.out.format(“the %s jumped over the %s, %d times”, “cow”, “moon”, 2);
System.err.format(“the %s jumped over the %s, %d times”, “cow”, “moon”, 2);
String result = String.format(“the %s jumped over the %s, %d times”, “cow”,”moon”, 2);
%c character
%d decimal (integer) number (base 10)
%e exponential floating-point number
%f floating-point number
%i integer (base-10)
%o octal number (base-8)
%s a string of characters
%u unsigned decimal (integer) number
%x number in hexadecimal (base 16)
%% print a percent sign
\% print a percent sign