While working in a Java app, I recently needed to assemble a comma-delimited list of values to pass to another web service without knowing how many elements there would be i
If you are using Spring MVC then you can try following steps.
import org.springframework.util.StringUtils; List groupIds = new List; groupIds.add("a"); groupIds.add("b"); groupIds.add("c"); String csv = StringUtils.arrayToCommaDelimitedString(groupIds.toArray());
It will result to a,b,c
a,b,c