Java List转换成String数组几种实现方式详解

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); 
} 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!