如何转换List< String>进入逗号分隔的字符串而不显式迭代List [英] How to convert a List<String> into a comma separated string without iterating List explicitly
本文介绍了如何转换List< String>进入逗号分隔的字符串而不显式迭代List的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
List<String> ids = new ArrayList<String>();
ids.add("1");
ids.add("2");
ids.add("3");
ids.add("4");
现在我希望此列表中的输出为1,2,3,4,而不是明确 迭代它。
Now i want an output from this list as 1,2,3,4 without explicitly iterating over it.
推荐答案
在Android上使用:
On Android use:
android.text.TextUtils.join(",", ids);
这篇关于如何转换List< String>进入逗号分隔的字符串而不显式迭代List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文