String[] array={"a","b","c","d"};怎么用迭代器遍历 大佬们
String[] array={"a","b","c","d"}; 大佬们怎么用迭代器遍历呢
String[] array={"a","b","c","d"}; 大佬们怎么用迭代器遍历呢
2018-04-03
package com.aa;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class Test {
public void testIterator(){
List<String> list = new ArrayList<String>();
String[] array={"a","b","c","d"};
list.addAll(Arrays.asList(array));
Iterator<String> it = list.iterator();
while(it.hasNext()){
String str = it.next();
System.out.println(str);
}
}
public static void main(String[] args) {
Test tt = new Test();
tt.testIterator();
}
}
举报