Home » Java programming language

Compare ArrayList and LinkedList in Java

Learn: Compare ArrayList and LinkedList in Java? What is the difference between ArrayList and LinkedList?
Submitted by Preeti Jain, on January 31, 2018

1) ArrayList in java

  1. ArrayList is a part of Collection interface.
  2. ArrayList is an implementation class of List interface (i.e. List is a child interface of Collection interface it means ArrayList is indirectly child class of Collection interface).
  3. ArrayList introduced three constructors:
    • ArrayList al = new ArrayList();
    • ArrayList al = new ArrayList(Collection c);
    • ArrayList al = new ArrayList(int capacity);
  4. Working of ArrayList Constructor are:
    • Default size (memory location will be 10 in blocks).
    • Defined Collection Object Size.
    • Defined by the user.
  5. ArrayList is recommended if our frequent operation is retrieval.
  6. Underlying data structure of ArrayList is array (array is resizable).
  7. ArrayList is not recommended where frequent operation is insertion or deletion.
  8. ArrayList implements RandomAcess interface (that’s why best choice for retrieval operation).

2) LinkedList in java

  1. LinkedList is a part of Collection interface.
  2. LinkedList is a implementation class of List interface (i.e. List is a child interface of Collection interface it means LinkedList is indirectly child class of Collection interface).
  3. LinkedList introduced two constructors:
    • LinkedList ll = new LinkedList();
    • LinkedList ll = new LinkedList(Collection c);
  4. Working of LinkedList Constructor are:
    • Default Size.
    • Defined Collection Object Size.
  5. LinkedList is recommended if our frequent operation is insertion or deletion (in the middle or from the middle).
  6. Underlying data structure of LinkedList is Doubly Linked List.
  7. LinkedList is not recommended where frequent operation is retrieval.
  8. LinkedList does not implements RandomAcess interface (thats why worst choice for retrieval operation).

Read more:






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.