Converting List to String[] in Java

后端 未结 6 1639
暖寄归人
暖寄归人 2020-12-25 10:52

How do I convert a list of String into an array? The following code returns an error.

public static void main(String[] args) {
    List strlist         


        
6条回答
  •  悲哀的现实
    2020-12-25 11:02

    hope this can help someone out there:

    List list = ..;

    String [] stringArray = list.toArray(new String[list.size()]);

    great answer from here: https://stackoverflow.com/a/4042464/1547266

提交回复
热议问题