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

ArrayList and LinkedList

 
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
Marshal
Pie
Posts: 20997
76
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic