File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections : Help Needed 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 "Collections : Help Needed" Watch "Collections : Help Needed" New topic

Collections : Help Needed

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 392
on Page 542 :
ArrayList : Choose this over a LinkedList when you need fast iteration but aren't as likely to be doing a lot of insertion and deletion.


on page 544 : Although itwill be somewhat slower than HashMap for adding and removing elements, you can expect faster iteration with a LinkedHashMap.

This means that one must choose {ArrayList over LinkedList} and {LinkedHashMap over HashMap} for fast iteration. Is this correct or a typo (bug) as these 2 statements are oposite of each other...
Bing Qiao

Joined: Oct 24, 2006
Posts: 21
I had doubt about that too.

But then I thought maybe it was due to the difference between Map and List.
Matthew Gerald

Joined: Sep 11, 2006
Posts: 10
I found an interesting link here:

It seems as though the book is correct due to LinkedHashMap actually using a LinkedList for iteration purposes. So what I'm assuming is that the LinkedList iteration is faster than HashMap iteration. So, LinkedHashMap is then faster for iteration than HashMap due to using that LinkedList.

-------------------------<br />SCJP 1.4 10/28/2006<br />SCWCD (next on the list!)
I agree. Here's the link:
subject: Collections : Help Needed
jQuery in Action, 3rd edition