How to add right aligned spaces to make ascii table line up properly when using System.out.printf()? I am trying to print an ascii table that requires me to use System.out.printf(); and input from a 2-dimensional array. The array has 3 columns and 8 rows and contains these values. 10 1 2 100 0 1 1000 0 2 10000 1 3 100000 6 27 1000000 46 53 10000000 105 1192 100000000 954 11261 When trying to print the table with this method: public static void print2dAsciiTable( long[][] data ) { String spacer = "+---------------+-----------+-----------+\n"; System.out.printf( spacer ); for (int row = 0; row < data.length; row++) { System.out.printf( "| %,5d | %,7d | %,7d |\n", data[row][0], data[row][1], data[row][2] ); System.out.printf( spacer ); } } I get this output: How can I make it line up properly to have many spaces on the left of each number in the first column with only 2 buffer spaces on the right side like it currently has? I need the output to resemble this: Thank you! .