0% found this document useful (0 votes)
208 views

Difference Between ArrayList and LinkedList - Javatpoint

ArrayList and LinkedList both implement the List interface but have key differences. ArrayList uses an internal array to store elements while LinkedList uses a doubly-linked list. Manipulation of elements is slower for ArrayList than LinkedList due to memory shifting during removal. ArrayList is better for storing and accessing data while LinkedList is better for manipulating data.

Uploaded by

manoj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
208 views

Difference Between ArrayList and LinkedList - Javatpoint

ArrayList and LinkedList both implement the List interface but have key differences. ArrayList uses an internal array to store elements while LinkedList uses a doubly-linked list. Manipulation of elements is slower for ArrayList than LinkedList due to memory shifting during removal. ArrayList is better for storing and accessing data while LinkedList is better for manipulating data.

Uploaded by

manoj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

5/17/2021 Difference between ArrayList and LinkedList - javatpoint

Difference between ArrayList and LinkedList


ArrayList and LinkedList both implements List interface and maintains insertion order.
Both are non synchronized classes.

However, there are many differences between ArrayList and LinkedList classes that are
given below.

ArrayList LinkedList

1) ArrayList internally uses a dynamic LinkedList internally uses a doubly


array to store the elements. linked list to store the elements.

2) Manipulation with ArrayList is slow Manipulation with LinkedList is faster


because it internally uses an array. If any than ArrayList because it uses a
element is removed from the array, all the doubly linked list, so no bit shifting is
bits are shifted in memory. required in memory.

3) An ArrayList class can act as a list only LinkedList class can act as a list and
because it implements List only. queue both because it implements
List and Deque interfaces.

4) ArrayList is better for storing and LinkedList is better for


accessing data. manipulating data.

Example of ArrayList and LinkedList in Java


Let's see a simple example where we are using ArrayList and LinkedList both.

https://www.javatpoint.com/difference-between-arraylist-and-linkedlist 1/4
5/17/2021 Difference between ArrayList and LinkedList - javatpoint

import java.util.*;

class TestArrayLinked{

public static void main(String args[]){

List<String> al=new ArrayList<String>();//creating arraylist

al.add("Ravi");//adding object in arraylist

al.add("Vijay");

al.add("Ravi");

al.add("Ajay");

List<String> al2=new LinkedList<String>();//creating linkedlist

al2.add("James");//adding object in linkedlist

al2.add("Serena");

al2.add("Swati");

al2.add("Junaid");

System.out.println("arraylist: "+al);

System.out.println("linkedlist: "+al2);

Test it Now

Output:

arraylist: [Ravi,Vijay,Ravi,Ajay]
linkedlist: [James,Serena,Swati,Junaid]

← Prev Next →

Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

Learn Latest Tutorials

https://www.javatpoint.com/difference-between-arraylist-and-linkedlist 2/4
5/17/2021 Difference between ArrayList and LinkedList - javatpoint

SoapUI RPA tutorial manual testing cucumber


tutorial tutorial tutorial
RPA
SoapUI Manual T. Cucumber

Appium postgresql Apache Solr MongoDB


tutorial tutorial Tutorial tutorial

Appium PostgreSQL Solr MongoDB

Gimp Tutorial Verilog Teradata PhoneGap


Tutorial Tutorial Tutorial
Gimp
Verilog Teradata PhoneGap

Preparation

Aptitude Logical Verbal Ability Interview


Reasoning Questions
Aptitude Verbal A.
Reasoning Interview

Company
Interview
Questions

Company

Trending Technologies

Artificial AWS Tutorial Selenium Cloud tutorial


Intelligence tutorial
Tutorial AWS Cloud
Selenium
AI

Hadoop ReactJS Data Science Angular 7


tutorial Tutorial Tutorial Tutorial

Hadoop ReactJS D. Science Angular 7

Blockchain Git Tutorial Machine DevOps


Tutorial Learning Tutorial Tutorial
Git
Blockchain ML DevOps

B.Tech / MCA

https://www.javatpoint.com/difference-between-arraylist-and-linkedlist 3/4
5/17/2021 Difference between ArrayList and LinkedList - javatpoint

DBMS tutorial Data DAA tutorial Operating


Structures System tutorial
DBMS tutorial DAA
OS
DS

Computer Compiler Computer Discrete


Network tutorial Design tutorial Organization and Mathematics
Architecture Tutorial
C. Network Compiler D.
COA D. Math.

Ethical Computer Software html tutorial


Hacking Tutorial Graphics Tutorial Engineering
Tutorial Web Tech.
E. Hacking C. Graphics
Software E.

Cyber Automata C Language C++ tutorial


Security tutorial Tutorial tutorial
C++
Cyber Sec. Automata C

Java tutorial .Net Python tutorial List of


Framework Programs
Java tutorial Python
Programs
.Net

Control Data Mining


Systems tutorial Tutorial

Control S. Data Mining

https://www.javatpoint.com/difference-between-arraylist-and-linkedlist 4/4

You might also like