java - What is this for loop with a colon? -


this question has answer here:

i reading example in textbook (finding path of file recursively) , came across format loop

for (file folderitem : dir.listfiles()){} 

the loop i'm used

for (int = 0; < 10; i++){} 

how loop work, , logic behind it?

this new type of loop (introduced in java 5). used iterate on types of collections. it's identical to

file[] files = dir.listfiles(); (int = 0; < files.length; i++) {     file folderitem = files[i];     // code } 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -