java - What is this for loop with a colon? -
this question has answer here:
- what for(:) mean in java? 2 answers
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
Post a Comment