how to print matrix without brackets and commas in java

www.‮‬lautturi.com
how to print matrix without brackets and commas in java
/**
 * @author lautturi.com
 * Java example: print 2d array without brackets and commas in java
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {

		int arr[][] = { {1,2,3,4},{5,6,7,8},{9,10,11,12} };
		for (int i = 0; i < arr.length; i++) { // for each row
			String row = Arrays.toString(arr[i]).replace(",", "") // remove the commas
					.replace("[", "") // remove the left bracket
					.replace("]", "") // remove the right bracket
					.trim(); // remove trailing spaces from partially initialized arrays
			System.out.println(row);
		}

	}
}

output:

1 2 3 4
5 6 7 8
9 10 11 12
Created Time:2017-09-12 22:41:01  Author:lautturi