這里的for是Java中forEach, 用來遍歷數組的。
for(int i : d) 就是遍歷int型數組d的 每一次訪問數組d的時候讀取的數據放入int型的i中。
和for(int i=0;i<d.length();i++)是一樣的,但是forEach的可用場合較多。
public class e1 {
public static void main(String[] args){
int[]d=new int[] {1,2,3,4,64,1234,3124,657,22};
System.out.println("d.length="+d.length);
for(int i : d){
System.out.println(i);
}
轉載于:https://www.cnblogs.com/AceIsSunshineRain/p/5095212.html