I need to display some matrices to view (java fx is used). I have string which contains matrices. The problem is that when I want to display it to view, the corresponding columns are not at the right place, for example
1 4 6
23 15 17
3 6 25
So as you can see, because numbers has different number of digits, it does not show correctly... Code for printing:
public static void printMatrix(double[][] matrix) {
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
String x = String.format("%5d ", (int) matrix[i][j]);
Helper.matrixString += x;
}
Helper.matrixString += System.lineSeparator();
}
}