hi all
im janaka priyadarsahana,

i got this code segment from the sun java tutorial. but cant understand how this for loop works.

out.print("File system roots: ");
for (File root : File.listRoots()) {
out.format("%s ", root);

please if anyone can help me......

thank you......

Recommended Answers

All 2 Replies

Read up in the Java 5.0/JDK 1.5 New Features Document at Sun. This is the "improved for loop or so-called for each loop".

the for loop is newly introduced in 1.5 its basically says for each file in the listRoot do

out.format("%s ", root);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.