Java tutorial
//package com.java2s; //License from project: Apache License import android.text.TextUtils; import java.util.Set; public class Main { public static final String COMMA = ","; /** * set convert to string */ public static String setConvertToString(Set<String> values, String separate) { if (values == null) { return null; } if (values.isEmpty()) { return ""; } String sp = TextUtils.isEmpty(separate) ? COMMA : separate; StringBuilder sb = new StringBuilder(64); int _size = values.size() - 1; int count = 0; for (String value : values) { sb.append(value); if (count != _size) { sb.append(sp); } count++; } return sb.toString(); } }