标签:
package test; import java.util.List; import java.util.ArrayList; import java.util.Scanner; /** * @author 年浩 * */ public class test { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); List<String>list = new ArrayList<String>(); list.add("abc"); list.add("def"); list.add("ghi"); list.add("jkl"); list.add("mno"); list.add("pqr"); System.out.println("用foreach循环遍历list:"); for(String string:list){//遍历list集合 System.out.println(string); } System.out.println(); String[] strs = new String [list.size()]; list.toArray(strs); System.out.println("用foreach遍历数组"); for(String str:strs){ System.out.println(str); } } }
标签:
原文地址:http://www.cnblogs.com/superxuezhazha/p/5406379.html