ArrayList 转 数组 和 数组 转 List
ArrayList 转 数组:
//list 转数组 ArrayList<String> list=new ArrayList<>(); list.add("A"); list.add("B"); list.add("C"); String str[]=(String[])list.toArray(new String[list.size()]);//转数组 for(String v:str) { System.out.println(v); }
数组 转 List:
//数组转list String[] str1= {"哈哈","嘻嘻","呵呵"}; List<String> list1 = Arrays.asList(str1);//转list System.out.println(list1);
输出结果: