提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将ArrayList转换为字符串数组
import java.util.ArrayList; import java.util.Arrays; /* 来 自* N o w J a v a . c o m */ public class Main { public static void main(String args[]){ ArrayList<String> aListDays = new ArrayList<String>(); aListDays.add("Sunday"); aListDays.add("Monday"); aListDays.add("Tuesday"); Object[] objDays = aListDays.toArray(); /**来自 n o w j a v a . c o m - 时 代 Java**/ String[] strDays = Arrays.copyOf(objDays, objDays.length, String[].class); System.out.println("ArrayList converted to String array");