Java List into an String array
- 2020-05-26 09:13:49
- OfStack
Java List is converted to String array
Implementation code:
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);
}
or
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);
}
Thank you for reading, I hope to help you, thank you for your support of this site!