Converting 'ArrayList to 'String[]' in Java

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

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

16条回答
  •  囚心锁ツ
    2020-11-22 02:41

    private String[] prepareDeliveryArray(List deliveryServices) {
        String[] delivery = new String[deliveryServices.size()];
        for (int i = 0; i < deliveryServices.size(); i++) {
            delivery[i] = deliveryServices.get(i).getName();
        }
        return delivery;
    }
    

提交回复
热议问题