how to print output of the loop as an array in java code example Example: java print array System.out.println(Arrays.toString(arr));