While using System.out.printf in Java, can I use the precision specifier to format an integer variable, such that it prepends the integer with zeros? If yes, how?
I need to get an output like
+0061
(such that 61 is the integer and the + sign is forced and the two zeros are prepended by the precision specifier)
and I tried using
System.out.printf("%+.4d" , number);
but it throws an exception to me at runtime.
2007-04-05
21:15:06
·
1 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design