Search code examples
javamultidimensional-arrayalignment

Aligning a multidimensional array in java?


Is there a way to align the columns of a multidimensional array to make all the values of a column line up properly. For example this is what happens when I System.out my code.

    Mon Tue Wed Thurs Fri Sat Sun Average
1   5.0 5.0 5.0 5.0 5.0 5.0 5.0 5
2   5.0 5.0 5.0 5.0 5.0 5.0 5.0 5
3   5.0 5.0 5.0 5.0 5.0 5.0 5.0 5
4   5.0 5.0 5.0 5.0 5.0 5.0 5.0 5

Towards the end because of Thurs text it starts of off set my columns. Is there a way I can line them up?


Solution

  • Take a look at System.out.printf.