java 數組和list轉換

list(ArrayList)轉數組

//要轉換的list集合
 List<String> testList = new ArrayList<String>(){{add("aa");add("bb");add("cc");}};

 //使用toArray(T[] a)方法
 String[] array2 = testList.toArray(new String[testList.size()]);
 

數組轉List

ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(arrays));

 

https://blog.csdn.net/x541211190/article/details/79597236

https://blog.csdn.net/zjx2016/article/details/78273192

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章