Results 1 to 4 of 4
  1. #1
    JavaForums's Avatar
    JavaForums is offline Administrator
    Join Date
    Dec 2006
    Posts
    877
    Rep Power
    10

    Default Enhanced for-loop (Java 5.0)

    Java 5.0 introduced an enhanced for-loop. In this post, Ill write about it.
    (more…)

  2. #2
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    10

    Default

    Thanks for that. Very interesting.. I've seen this type of For loop before but didn't look into it. I actually prefere the original For loop but I guess thats just because I already know it well. I'm going to make a conscious effort to use this new structure in the future.
    Did this post help you? Please me! :cool:

  3. #3
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    10

    Default

    I have the same behavior. I still dont use the new features introduced with Java 1.5.

  4. #4
    elizas is offline Member
    Join Date
    Jan 2010
    Location
    India
    Posts
    4
    Rep Power
    0

    Default Enhanced for loop in java

    Old form of looping.

    for (int i=0; i < nameArray.length; i++)
    {
    System.out.println("Name: " + array[i]);
    }
    With Java SE 5.0. an enhanced looping would be like

    for (String name : nameArray)
    {
    System.out.println("Name: " + name);
    }

    where nameArray is an array of Strings

Similar Threads

  1. Replies: 0
    Last Post: 11-14-2007, 04:22 PM
  2. Enhanced for loop
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-03-2007, 10:24 PM
  3. Help with loop in java
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 07:36 AM
  4. Help, loop with java
    By cachi in forum New To Java
    Replies: 5
    Last Post: 08-01-2007, 06:03 AM
  5. Enhanced For loop In Java
    By goldhouse in forum Advanced Java
    Replies: 1
    Last Post: 05-06-2007, 04:26 PM

Posting Permissions

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