English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

1 answers

Try this web site. There is more information on the links too.

2007-04-05 23:22:27 · answer #1 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers