Home> Java> javaTutorial> body text

Detailed explanation of several implementation methods for converting Java List into String array

高洛峰
Release: 2017-01-21 16:25:11
Original
2374 people have browsed it

Java List converted into String array

Implementation code:

List list = new ArrayList(); list.add("a1"); list.add("a2"); String[] toBeStored = list.toArray(new String[list.size()]); for(String s : toBeStored) { System.out.println(s); }
Copy after login

or

List list = new ArrayList(); list.add("a1"); list.add("a2"); String[] toBeStored = new String[al.size()]; list.toArray(toBeStored); for (String s : toBeStored) { System.out.println(s); }
Copy after login

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!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!