Java List converted into 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); }
Thanks for reading, I hope you can This helps everyone, thank you for your support of this site!
For more detailed explanations of several implementation methods for converting Java List into String array, please pay attention to the PHP Chinese website!