What's the best way to convert a string array to a delimiter separated string.
eg:
String[] arr = {"apple","orange","banana","round"};
-------> apple-orange-banana-round?
What's the best way to convert a string array to a delimiter separated string.
eg:
String[] arr = {"apple","orange","banana","round"};
-------> apple-orange-banana-round?
You can use a StringBuffer or StringBuilder (StringBuffer is thread safe) to make this:
StringBuffer sb = new StringBuffer();
for(String s : arr){
sb.append(s + "-");
}
sb.deleteCharAt(sb.length()-1);
return sb.toString();
Does this make sense to you?