My requirement is that I have to write a java method in my class which will accept a List<String>
as a parameter. Now I have to concatenate
public String encode(List<String> ls){
StringBuffer sb = new StringBuffer();
ListIterator<String> lis = ls.listIterator();
while(lis.hasNext()){
sb.append(lis.next());
/*my code here
* sb.append(lis.next());
* sb.append(some delim);
*
*
*/
}
//my code here
return sb.toString();
}
Now those String in the List can contains any value(char/num/special char etc), so I cannot use common delimiters like ,/:/;
etc. Please suggest me the way to do the concatenate.
Also going forward I may need to split the same concatenated string for my different method. So I need to use some delimiter or other option which can be used later for creating the list once again.