String和List的互换

一、String转成List<String>

       可自己写方法

       JSONArray.parseArray(list, String.class);这个是阿里巴巴的fastjson的封装好的方法

      

二、List<String>转成String

Joiner.on(",").join(list); 这个方法是google的Joiner类专门用来连接String

StringUtils.join();这个是apache提供的方法类

String.join();这个是JDK8提供的方法

还有一种最简单的就是直接list.toString()

发布了33 篇原创文章 · 获赞 23 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/SunFlowerXT/article/details/88849351
今日推荐