Arraylist of strings into one comma separated string

前端 未结 4 666
暗喜
暗喜 2021-01-15 11:57

Trying to convert a Arraylist of strings into one big comma separated string.

However when I use the

String joined = TextUtils.join(\", \", partici         


        
4条回答
  •  长情又很酷
    2021-01-15 12:54

    I don't know what TextUtils does. This will do it.

    StringBuffer sb = new StringBuffer();
    for (String x : participants) {
        sb.append(x);
        sb.append(", ");
    }
    return sb.toString();
    

    Easy enough, just use that.

提交回复
热议问题