字符串数组通过集合遍历

 1 package cn.collection.com;
 2 
 3 import java.util.ArrayList;
 4 import java.util.Iterator;
 5 import java.util.List;
 6 
 7 public class ListDemo3 {
 8 
 9     public static void main(String[] args) {
10         // TODO Auto-generated method stub
11         List ls = new ArrayList();
12 
13         String[] student = { "zhang", "san", "li", "si" };
14         
15         for (int y = 0; y < student.length; y++) {
16             String st = student[y];
17             ls.add(st); // 字符串数组放到集合中
18         }
19 
20         Iterator it = ls.iterator();// 把集合遍历
21         while (it.hasNext()) {
22             String ss = (String) it.next();
23             System.out.println(ss);
24         }
25 
26     }
27 
28 }
原文地址:https://www.cnblogs.com/yschung/p/9303993.html