Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7886053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:13:30+00:00 2026-06-03T05:13:30+00:00

Consider for(File file : files ) in the following code. I’ve never seen this

  • 0

Consider for(File file : files ) in the following code. I’ve never seen this syntax before. I understand from context and behavior that it’a a for loop based on the number of records…similar to (for x=0;x<length.foo;++x). Beyond that though, I’m not sure. Is this shorthand for a for loop that I’ve not learned yet? Is this a loop specifically for objects? More importantly… how do I describe it when I want to google information about that particular syntax?

CLARIFICATION: a second question, I’m also curious how this method of recursive file listing stores the list of filenames in file. Is this an array? a collection? or…? I’d like to know how I need to read the resulting file.

public static void main(String... aArgs) throws FileNotFoundException
{
    File startingDirectory= new File("CGT");
    List<File> files = WorkingFileListing2.getFileListingNoSort(startingDirectory);
    for(File file : files )
    {
       System.out.println(file);  //print filenames
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:13:32+00:00Added an answer on June 3, 2026 at 5:13 am

    It looks to me like the equivalent of a ‘foreach’ in C#. Searching Google for ‘Java foreach’ got me this:
    Detail on Java For-Each loop

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code for printing questions from text file: foreach ($lines as $line_num
Consider this scenario: I've an XML file called person.xml with the following data in
Consider a snippet of CSS code from a .css file in Visual Studio 2010
The following NewLISP code shows me the file attributes of files under Win32. However,
Consider a compressed Javascript file (containing few merged javascript files) called compressed.js . This
Please consider the following: I am storing around 1.2 Million TIF files ranging from
Consider the following code: [context performBlock:^{ // add a bunch of objects to context
Consider following code: Dim S1 As String = a 'this is the string in
Consider the following code: function Dog() { this.foo = function() {}; this.walk = function()
I would like to understand the ServiceBehavior.ConcurrencyMode property. Consider the following code on service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.