How to convert ArrayList to String[] in java, Arraylist contains VO objects

前端 未结 1 1311
温柔的废话
温柔的废话 2021-02-13 06:24

Please help me to convert ArrayList to String[]. The ArrayList contains values of type Object(VO).

For example,

The problem is that I need to convert a country L

相关标签:
1条回答
  • 2021-02-13 06:28
    String [] countriesArray = countryList.toArray(new String[countryList.size()]);
    

    I have assumed that your country List name is countryList.

    So to convert ArrayList of any class into array use following code. Convert T into the class whose arrays you want to create.

    List<T> list = new ArrayList<T>();    
    T [] countries = list.toArray(new T[list.size()]);
    
    0 讨论(0)
提交回复
热议问题