且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

转换列表<字符串>Java中的字符串[]

更新时间:2022-11-22 13:04:10

你想要的

String[] strarray = strlist.toArray(new String[0]);

参见这里 获取文档并注意,您还可以通过填充传递的数组的方式调用此方法,而不仅仅是使用它来计算要返回的类型.另请注意,当您打印数组时,您可能更喜欢

See here for the documentation and note that you can also call this method in such a way that it populates the passed array, rather than just using it to work out what type to return. Also note that maybe when you print your array you'd prefer

System.out.println(Arrays.toString(strarray));

因为这将打印实际的元素.

since that will print the actual elements.