[Solved] Replace Brackets on Array


You can try with

array.stream().map(s->"\""+s+"\"").collect(Collectors.joining(", "));

which will first surround each strings with quotes, then join them using ,

For Java 7

String delimiter = ", ";
StringBuilder sb = new StringBuilder();

if (!array.isEmpty()) {
    sb.append('"').append(array.get(0)).append('"');
}
for (int i = 1; i < array.size(); i++) {
    sb.append(delimiter).append('"').append(array.get(i)).append('"');
}

String result = sb.toString();

3

solved Replace Brackets on Array