File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 18117
    
  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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ArrayList and LinkedList
 
Similar Threads
collecition class
Question from Devaka's Practice 1
Linked List and Linked Hash Map
LinkedList
Arraylist insert at specific index performance query