ArrayList转数组:
public class Test { public static void main(String[] args) { List数组转ArrayList:list = new ArrayList (); list.add("王利虎"); list.add("张三"); list.add("李四"); int size = list.size(); String[] array = (String[]) list.toArray(new String[size]); for (int i = 0; i < array.length; i++) { System.out.println(array[i]); } } }
public class Test { public static void main(String[] args) { String[] array = new String[3]; array[0] = "王利虎"; array[1] = "张三"; array[2] = "李四"; Listlist = Arrays.asList(array); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); } } }