Output ArrayList to String without [,] (brackets) appearing

Java 8 version

List<Integer> intList = new ArrayList<Integer>();
intList.add(1);
intList.add(2);
intList.add(4);
System.out.println(intList.stream().map(i -> i.toString()).collect(Collectors.joining(",")));

Output: 1,2,4


Can directly convert list/set to string and perform action on it

customers.toString().replace("[", "").replace("]", "")

You could try to replace the '[' and ']' with empty space

String list = Arrays.toString(customers.toArray()).replace("[", "").replace("]", "");

I think the best solution to print list without brackets and without any separator( for java 8 and higher )

String.join("", YOUR_LIST);

You can also add your own delimiter to separate printing elements.

String.join(", \n", YOUR_LIST);

example above separate each list element with comma and new line.