Using String.join method (from java 8)
1 2 |
String[] array = new String[] { "a", "b", "c" }; String joined2 = String.join(",", array); |
Using simple for-loop expression
1 2 3 4 5 6 |
StringBuilder sb = new StringBuilder(); for (String n : name) { if (sb.length() > 0) sb.append(','); sb.append("'").append(n).append("'"); } return sb.toString(); |
I want to convert into a string array. How do I do it? Is there any java built in function? Manually I can do it but I’m searching for a java built in function.
You can use String.join, it is built in from java 8.