- 说的是foreach,实际代码中写的仍然是: for
public class HelloWorld {
public static void main(String[] args){
int data [] = new int [] {1,2,3,4,5};
for(int temp : data){// 避免了下标的操作; 同样可以遍历“集合”
System.out.println(temp);
}
}
}