Java - Append quotes to strings in an array and join strings in an array
I would like to append double quotes to strings in an array and then later
join them as a single string (retaining the quotes). Is there any String
library which does this? I have tried Apache commons StringUtils and
Google guava but couldn't find anything that appends double quotes.
My input would be an array as mentioned below:
String [] listOfStrings = {"day", "campaign", "imps", "conversions"};
Required output should be as mentioned below:
String output = "\"day\", \"campaign\", \"imps\", \"conversions\"";
I know I can loop through the array and append quotes. But I would like a
more cleaner solution if there is one.
No comments:
Post a Comment