Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the use of this New Enhanced for loop feature ??

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,

I am trying to uunderstand the New For loop Enhanced Feature .

I have written this sample Example for my understanding purpose .



This works fine .
Could anybody tell me , with this new Enhanced feature will the performance would be increased ??
Or What is the use of this New Enhanced for loop feature ?? Please guide me , Thanks .
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran Va wrote:This works fine .

Try again with a LinkedList with several thousands of objects. See how well it performs.

Here's a little test program for you:
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main advantage is that it makes your source code simpler and easier to read. Using the new enhanced for loop does not automatically increase performance.

By the way, it isn't really that new anymore, it was introduced in Java 5 which was released in September 2004, more than six years ago...
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Rob Prime and Jesper de Jong , as usual you rock .
Anyways ,I know that , Posting a question in this Category (Java in General or Java Beginer ) will yield me prompt results
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic