Java 这条线在循环条件下是什么意思?

Java 这条线在循环条件下是什么意思?,java,for-loop,iteration,Java,For Loop,Iteration,可能重复: 这行的for循环条件是什么意思?这是java(或)增强的for循环 这意味着对于文件数组中的每个文件(或)都是可编辑的。for(file file:files)--在Java中是foreach循环,这与说,对于文件中的每个文件是相同的。其中,files是一个iterable,file是一个变量,其中存储的每个元素在for循环范围内暂时有效。请参见这表示对于一组文件中的每个文件,文件都要。。。(正文) 有关更多详细信息,请阅读。链接中的示例很棒。-这种形式的循环从1.5开始在Java

可能重复:

这行的for循环条件是什么意思?

这是java(或)增强的for循环


这意味着对于文件数组中的每个文件(或)都是可编辑的。

for(file file:files)
--在Java中是foreach循环,这与说,
对于文件中的每个文件是相同的。其中,
files
是一个iterable,
file
是一个变量,其中存储的每个元素在for循环范围内暂时有效。请参见

这表示对于一组文件中的每个文件,文件都要。。。(正文)


有关更多详细信息,请阅读。链接中的示例很棒。

-这种形式的循环从
1.5
开始在Java中出现,对于每个循环都称为

让我们看看它是如何工作的:

int[] arr = new int[5];    // Put some values in

for(int i=0 ; i<5 ; i++){  

// Initialization, Condition and Increment needed to be handled by the programmer

// i mean the index here

   System.out.println(arr[i]);

}
int[] arr = new int[5];    // Put some values in

for(int i : arr){  

// Initialization, Condition and Increment needed to be handled by the JVM

// i mean the value at an index in Array arr

// Its assignment of values from Array arr into the variable i which is of same type, in an incremental index order

   System.out.println(i);

}
For循环:

int[] arr = new int[5];    // Put some values in

for(int i=0 ; i<5 ; i++){  

// Initialization, Condition and Increment needed to be handled by the programmer

// i mean the index here

   System.out.println(arr[i]);

}
int[] arr = new int[5];    // Put some values in

for(int i : arr){  

// Initialization, Condition and Increment needed to be handled by the JVM

// i mean the value at an index in Array arr

// Its assignment of values from Array arr into the variable i which is of same type, in an incremental index order

   System.out.println(i);

}