Need help !

0 Muhammad Azhar Ilyas · March 12, 2015
can any one please explain what is the difference between ArrayList and LinkedList ? and what is the ideal situation to use Arraylist and LinkedList ! 

Post a Reply


Oldest  Newest  Rating
+1 Dol Lod · March 13, 2015
Consider using an ArrayList if you will be using a lot of random access, basically if you care less about insertions and deletions and more about retrieving data already present. LinkedLists are good b/c they don't require consecutive blocks like arrays and are good when insertions and deletions will be fairly common.

Use ArrayList if you you know that you want to receive specific elements quickly, assuming most operations performed will be retrieving specific elements from a collection.

Use LinkedList if you will only be using the collection as whole instead with most operations being insertions and deletions. 

Specific ex.

Use linkedlist if you want to record every word that begins with k and return it. 

Use arraylIst if you store things like different fields of an object and you want to quickly retrieve particular elements or attributes of a class. An example would be a person's name,id,favorite color and I wanted to quickly retrieve that information in one shot. I know you could just set up a class to handle it, but for 100 attributes, it's impractical.
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator