package com.kuaff.jdk5;
import java.util.*;
import java.util.Collection;
public class Foreach
{
private Collection<String> c = null;
private String[] belle = new String[4];
public Foreach()
{
belle[0] = "西施";
belle[1] = "王昭君";
belle[2] = "貂禅";
belle[3] = "杨贵妃";
c = Arrays.asList(belle);
}
public void testCollection()
{
for (String b : c)
{
System.out.println("曾经的风化绝代:" + b);
}
}
public void testArray()
{
for (String b : belle)
{
System.out.println("曾经的青史留名:" + b);
}
}
public static void main(String[] args)
{
Foreach each = new Foreach();
each.testCollection();
each.testArray();
}
} |