Java List轉換成String陣列
實作程式碼:
List<String> list = new ArrayList<String>(); list.add("a1"); list.add("a2"); String[] toBeStored = list.toArray(new String[list.size()]); for(String s : toBeStored) { System.out.println(s); }
或
List<String> list = new ArrayList<String>(); list.add("a1"); list.add("a2"); String[] toBeStored = new String[al.size()]; list.toArray(toBeStored); for (String s : toBeStored) { System.out.println(s); }
感謝閱讀,希望能幫忙到大家,謝謝大家對本站的支持!
更多Java List轉換成String陣列幾種實作方式詳解相關文章請關注PHP中文網!