I was wondering what the best way of printing a 2D array was. This is some code that I have and I was just wondering if this is good practice or not. Also correct me in any
System.out.println(Arrays.deepToString(array) .replace("],","\n").replace(",","\t| ") .replaceAll("[\\[\\]]", " "));
You can remove unwanted brackets with .replace(), after .deepToString if you like. That will look like:
.replace()
.deepToString
1 | 2 | 3 4 | 5 | 6 7 | 8 | 9 10 | 11 | 12 13 | 15 | 15