日期:2014-05-20 浏览次数:20836 次
package cc.openhome;
import java.util.*;
public class ForEach {
private static void forEach(Iterable<String> iterable) {
for (Object o : iterable) {
System.out.println(o);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
List<String> list = Arrays.asList("Justin", "Monica", "Irene");
//forEach(list);
forEach(new HashSet<String>(list));
//forEach(new ArrayDeque<String>(list));
}
}
Monica
Justin
Irene
Justin
Monica
Irene