• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ArrayList vs LinkedList !!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the differences between an ArrayList and a LinkedList ?
Where do we use ArrayList and where LinkedList ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ArrayList is implemented with an array to store the elements of the list. LinkedList is implemented as a doubly-linked list.

Which one you should use depends on how you use the list. An ArrayList is faster when you need to lookup an element at a known index in the list, but slower when you insert elements in the list. A LinkedList is slower when looking up an element at a known index in the list, but faster when you insert elements in the list.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding on top of what Jesper said, both of them are collections and used to deal with a heterogeneous elements in a sequence.

As they follow different implementation strategies, they have different characteristics. I think Jesper have given a good explanation on that.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://narencoolgeek.blogspot.com/2006/09/arraylist-vs-linkedlist.html
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amir Alagic:
http://narencoolgeek.blogspot.com/2006/09/arraylist-vs-linkedlist.html



This link is cool (also the links present inside the article).
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ArryList: we will use ArrayList in following cases
if the requirement contains more retrival operation then we have to use ArrayList

LinkedList: If the requirement contains more insertions and deletions then we will use LinkedList
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by raghu nagabandi:
ArryList: we will use ArrayList in following cases
if the requirement contains more retrival operation then we have to use ArrayList



Only for random access. If we always iterate through all elements of a list in order, a LinkedList should be just fine (although still a little bit slower).
reply
    Bookmark Topic Watch Topic
  • New Topic