Need definition for line of code please?

Hi

I need to know what this line of code means:
for(String fn : files)
System.out.println("found " + fn);

Could you please tell me what the "fn" function is for and why it is being used in this line of code?

Thank you very much

God Bless

Anonymous2012-09-20T05:48:40Z

Favorite Answer

What is happening here is its taking all the variables in 'files' and putting them through a loop. Each loop iteration it puts the current element of files into 'fn' so 'fn' can be called to do something with it. This is how the new c++ 'for each' loops work. If you want more information look up for each loops in something like c#

TheMadProfessor2012-09-20T13:20:12Z

fn is not a function, it's a variable that is being used to step thru a collection of strings named files. The code can be thought of as "Get each string from collection files sequentially, naming each occurrence fn and print it out."

animedragonfighter2012-09-20T12:18:16Z

fn appears to be a variable

exean2012-09-20T13:06:12Z

for(int i = 0; i < files.size(); i++)
System.out.println("found " + files.get[i]);