1. 程式人生 > >字串陣列轉換為ArrayList集合

字串陣列轉換為ArrayList集合

ArrayList<String> strs = new ArrayList<String>();
	System.out.println(strs.size());
	String[] newitems = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L" };
	List<String> items =  Arrays.asList(newitems);
	ArrayList<String> aitems = new ArrayList<String>(items);
List<String> list=new ArrayList<String>(); 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.print(array[i]); } for(String str:aitems) { System.out.print(str); }