• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayList and LinkedList  RSS feed

 
harsha balluru
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see that ArrayList is mainly for faster iteration and fast random access while LinkedList for faster insertion and deletion. Both are ordered but not sorted. My question is that "does anyone disagree if I say LinkedList is ordered by 'insertion order'(or last accessed order)?"
 
Henry Wong
author
Sheriff
Posts: 22861
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question is that "does anyone disagree if I say LinkedList is ordered by 'insertion order'(or last accessed order)?"


I would tend to disagree. Yes, if you only use the add(Element) method, then the list would be in "insertion order", the order which the elements were inserted. However, the List also have the ability to add() at a particular index, so the order may not be the order the elements were added.

Henry
 
harsha balluru
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!