- 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);
- }
或
- List<String> list = new ArrayList<String>();
- list.add("a1");
- list.add("a2");
- String[] toBeStored = new String[]{};
- String[] str = al.toArray(toBeStored);
- for (String s : str) {
- System.out.println(s);
- }
或
- String str[] = list.toArray(new String[]{});