aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Query on Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Query on Collections" Watch "Query on Collections" New topic
Author

Query on Collections

Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
Hi,

Can anyone please let me know that is iteration over linkedlist is faster than an ArrayList.

Regds,
Ritu
Manju Devarla
Ranch Hand

Joined: Dec 14, 2006
Posts: 85
Iteration of LinkedList is not faster than ArryList because elements are doubly linked to one another..
But its a good choice for faster insertion and deletions
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

For what it's worth, Bruce Eckel's Thinking in Java includes some performance comparisons under the Choosing an implementation section of the Collections chapter...
Oddly, iteration is faster for a LinkedList than an ArrayList, which is a bit counterintuitive.

[ January 25, 2007: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
I read a following question from a website.


It says the correct answers are: 1,2
I feel its only 1.

Please help.
Rgds,
Ritu
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Manju Devarla:
Iteration of LinkedList is not faster than ArryList because elements are doubly linked to one another...

What does being doubly linked have to to with iteration performance?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
following question from a website
. Please tell us which website. If you quote a mock exam question always provide the reference. We will close topics if the source is not quoted. Thanks.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
The source of mock exam is http://www.akgupta.com/Java/mock_exam.htm
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Originally posted by Ritu Kapoor:
The source of mock exam is http://www.akgupta.com/Java/mock_exam.htm


Great. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query on Collections