Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exact Difference Between LinkedList and ArrayList

 
Pawar Santoshkumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
USING ARRAYLIST AND LINKEDLIST
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic