aspose file tools*
The moose likes Beginning Java and the fly likes ArrayList and LinkedList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList and LinkedList " Watch "ArrayList and LinkedList " New topic
Author

ArrayList and LinkedList

harsha balluru
Greenhorn

Joined: Feb 06, 2009
Posts: 14
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

Joined: Sep 28, 2004
Posts: 18141
    
  39

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
harsha balluru
Greenhorn

Joined: Feb 06, 2009
Posts: 14
Thanks Henry.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList and LinkedList
 
Similar Threads
collecition class
LinkedList
Question from Devaka's Practice 1
Linked List and Linked Hash Map
Arraylist insert at specific index performance query