Converting 'ArrayList to 'String[]' in Java

前端 未结 16 1531
情书的邮戳
情书的邮戳 2020-11-22 01:59

How might I convert an ArrayList object to a String[] array in Java?

16条回答
  •  臣服心动
    2020-11-22 02:52

    In Java 8, it can be done using

    String[] arrayFromList = fromlist.stream().toArray(String[]::new);
    

提交回复
热议问题