Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
String line = "5 1973 2205 2396 2406"; String[] paperids = line.split(" "); List<String> paperList = Arrays.asList(paperids); paperList.remove(0);
这是我的 Java 代码,我想将 string[] 转移到 List 并删除 List 的第一项,但它在最后一行不起作用,有人可以帮我吗?非常感谢。
List返回的 from是Arrays.asList不可变的(不能更改)。这实际上是一个(烦人的)功能List
List
Arrays.asList
尝试创建一个ArrayList并使用数组值播种它
ArrayList
String line = "5 1973 2205 2396 2406"; String[] paperids = line.split(" "); List<String> paperList = new ArrayList<String>(Arrays.asList(paperids)); paperList.remove(0);