I am trying to produce right aligned numbers looking a bit like this:
12345
2345
but I clearly does not understand the syntax. I have been trying to follow these instructions. and Come up with the following attempt (it is integers so d and I want width 7 and 0 decimals):
public class test {
public static void main( String[] args ) {
System.out.format("%7.0d%n", 12345);
System.out.format("%7.0d%n", 2345);
}
}
but no matter what I do I seem to end up with IllegalFormatPrecisionException. Is there a way to do this using this tool? If not how else would you do it?
.0is for floating point. You don't need it.