• 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

Exact Difference Between LinkedList and ArrayList

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody tell me exact difference between Linked List and Array List.
Please give Example By Usage of Both in JavaCode.
Thanks in Advance.
 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pawar santosh:
Can anybody tell me exact difference between Linked List and Array List.
Please give Example By Usage of Both in JavaCode.
Thanks in Advance.



Well Pawar,
The biggest difference between is

LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.

Although you can check out the books on Collections for time being I can tell you.

An Array is a "special" object in Java that has very few methods. You can access the value in the array the [ ] brackets, and you can determine the length (the .length) property, and thats about the extent of the Array. The array has a FIXED size that cannot be changed.

The ArrayList is part of the Collections Framework. It is a List that is built on top of an array. It provides methods to add to the list (thereby changing the size), as well as to obtain an iterator, and to remove elements, sort elements, and perform searches. Basically, it saves you from having to write that code when using an array.

The LinkedList is also a List. It essentially provides the same methods as the ArrayList, except the underlying data structure uses objects that contain references to other objects to form a list. This is "similar" to the concept other languages call "pointers" (but not quite the same).


I hope I make it clear you.
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
USING ARRAYLIST AND LINKEDLIST
 
reply
    Bookmark Topic Watch Topic
  • New Topic