Results 1 to 3 of 3
  1. #1
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

    Default What does : mean?

    I'm looking at some Java code which looks like this:

    for(String fileName : args)

    what does that do/mean?

    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    That is a new version of the for loop called a foreach loop. Read it as such: for each String, (that we'll give the name fileName) in the array or collection args do...

    This:
    Java Code:
    for(String fileName : args)
    {
       System.out.println("File Name Is: " + fileName);
    }
    is the same as this:
    Java Code:
    for(int i = 0; i < args.length; i++)
    {
       System.out.println("File Name Is: " + args[i]);
    }

  3. #3
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •