1. Array轉ArrayList
String[] values= {"A","B","C","D"};
ArrayList ChangeArrayList = new ArrayList(Arrays.asList(values));
2. ArrayList轉Array
ArrayList ValueList = new ArrayList();
ValueList.add("A");
ValueList.add("B");
...
String[] values = ValueList.toArray(new String[0]);
取Array的數量用:length
取ArrayList的數量用:size()
沒有留言:
張貼留言