您的位置:首页 > 编程语言 > Java开发

【Java基础】将数组转换为List或者LinkedList

2017-08-21 21:22 1266 查看
将数组转换为List:

String[] ids = proHist.split("#");
//将ids转化为list集合
Collection<String> collection = Arrays.asList(ids);


将List转换为LinkedList:

LinkedList<String> list = new LinkedList<>(collection);


将LinkedList转换为String

//将linkedlist转换为string
StringBuffer sBuffer=new StringBuffer();
for (String string : list) {
sBuffer.append(string);
}
String result = sBuffer.toString();
result=result.substring(0, result.length());
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java string linkedlist