package com.bowenxu.struct;
import java.util.ArrayList;
import java.util.Collection;
public class Demo08 {
public static void main(String[] args) {
//增强for循环。用于遍历数组和集合,相当于c#的foreach
//数组
int[] numbers ={10,20,30,40,50};
for (int a:numbers)
{
System.out.println(a);
}
//集合
Collection <String> names = new ArrayList<String>();
names.add("HelloWorld");
names.add("X-man");
names.add("Supper-man");
names.add("Flash-man");
names.add("Fire-man");
System.out.println("上面是数组=============下面是集合");
for (String s:names)
{
System.out.println(s);
}
}
}