If you convert your array to Eclipse Collections (formerly GS Collections ), you can use one of the makeString() methods. If you do not pass the separator parameter, it defaults to "," (comma and space).
MutableList<Integer> integers = Lists.mutable.with(1, 2, 3, 4, 5); String s1 = integers.makeString(","); // "1,2,3,4,5" String s2 = integers.makeString(); // "1, 2, 3, 4, 5"
Note: I am a committer for Eclipse collections
Donald raab
source share