| Author |
What is the use of this New Enhanced for loop feature ??
|
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
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 .
|
Save India From Corruption - Anna Hazare.
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8147
|
|
http://download.oracle.com/javase/1.5.0/docs/guide/language/foreach.html
|
[My Blog] [JavaRanch Journal]
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
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:
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
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...
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
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
|
 |
 |
|
|
subject: What is the use of this New Enhanced for loop feature ??
|
|
|