【积累】string和list

string和list

  1. string转list逗号分隔
java 复制代码
Arrays.asList(str.split(","));
  1. string转list后,不能对list进行修改操作,如果要修改再转化一次后得到的list可以进行修改
java 复制代码
List<String> strList =new ArrayList<>(Arrays.asList(str.split(",")));

参考:java.lang.UnsupportedOperationException: null异常处理

  1. list转string,以逗号分隔
java 复制代码
String.join(",", list);
  1. string转List
java 复制代码
List<String> strings = Arrays.asList(integerList.split(","));

参考:list集合转换成string字符串

相关推荐
曾几何时`1 小时前
C++——this指针
开发语言·c++
盖世英雄酱581361 小时前
commit 成功为什么数据只更新了部分?
java·数据库·后端
小冯的编程学习之路1 小时前
【C++】: C++基于微服务的即时通讯系统(1)
开发语言·c++·微服务
码上淘金2 小时前
在 YAML 中如何将 JSON 对象作为字符串整体赋值?——兼谈 Go Template 中的 fromJson 使用
java·golang·json
刘一说2 小时前
Spring Boot 应用的指标收集与监控体系构建指南
java·spring boot·后端
穿西装的水獭2 小时前
python将Excel数据写进图片中
开发语言·python·excel
老友@2 小时前
Java Excel 导出:EasyExcel 使用详解
java·开发语言·excel·easyexcel·excel导出
Full Stack Developme3 小时前
java.net.http 包详解
java·http·.net
tryCbest3 小时前
Python基础之爬虫技术(一)
开发语言·爬虫·python
hixiong1233 小时前
C# OpenCVSharp实现Hand Pose Estimation Mediapipe
开发语言·opencv·ai·c#·手势识别