java如何正确地将字符串转换为ArrayList?
我想把这个String
转换成一个ArrayList
字符串
["one","two","three"]
我用了这个方法
List<String> logopath = Arrays.asList(pos.split("\\s*,\\s*"));
我从logopath
得到这个输出
0 = "["one""
1 = ""two""
2 = ""three"]"
但是我希望logopath
的输出如下:
0 = "one"
1 = "two"
2 = "three"
# 1 楼答案
您的字符串实际上是有效的JSON,因此我建议在这里使用JSON解析器:
# 2 楼答案
可以通过以下方式实现: