I have this line of code:
Where solutions is a two-dimensional array. This is within a nested for loop, but don't worry about all of that. This line of code is successfully printing the value of "solutions", rounding to 1 decimal, and aligning each result to the far right of 8 spaces.
I want to align it in the center, not the far right.
So I looked at this site:
Complete Printf for Java Format String Specification
Which says I can use the "^" flag to center the result in the given specified width.
And that I should use this format: %[flags][width][.precision][argsize]typechar
So I wrote this code:
Which compiles, but creates a run time error.
This is the error:
HTML Code:Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '^' at java.util.Formatter.checkText(Formatter.java:2547) at java.util.Formatter.parse(Formatter.java:2533) at java.util.Formatter.format(Formatter.java:2469) at java.io.PrintStream.format(PrintStream.java:970) at java.io.PrintStream.printf(PrintStream.java:871) at HW1.printTable(HW1.java:95) at HW1.main(HW1.java:23)
What am I doing wrong?
Thanks in advance.