Using Java 8, you can easily perform the required function:
String.join(delimiter, elements);
This can work in 3 ways:
- Directly specifying the elements
String arr1 = String.join(",", "a", "b", "c");
String[] arr = new String[] { "a", "b", "c" };
String arr2 = String.join(",", array);
List<String> list = Arrays.asList(array);
String arr3= String.join(",", list);