把ArrayList转换成字符数组

import java.util.ArrayList;
import java.util.Arrays;

public class ConvertToStringArray {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    ArrayList aListDays = new ArrayList();
    aListDays.add("Sunday");
    aListDays.add("Monday");
    aListDays.add("Tuesday");
    Object[] objDays = aListDays.toArray();
   
    String[] strDays = Arrays.copyOf(objDays, objDays.length, String[].class);
   
    System.out.println("ArrayList converted to String array");
   
    for(int i=0; i < strDays.length; i++){
            System.out.println(strDays[i]);
    }
}

}
Console:
ArrayList converted to String array
Sunday
Monday
Tuesday

你可能感兴趣的:(把ArrayList转换成字符数组)