
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Differences between ArrayList and LinkedList in Java
Both ArrayList and LinkedList are implementation of List interface in Java. Both classes are non-synchronized. But there are certain differences as well.
Following are the important differences between ArrayList and LinkedList method.
Sr. No. | Key | ArrayList | LinkedList |
---|---|---|---|
1 | Internal Implementation | ArrayList internally uses a dynamic array to store its elements. | LinkedList uses Doubly Linked List to store its elements. |
2 | Manipulation | ArrayList is slow as array manipulation is slower. | LinkedList is faster being node based as not much bit shifting required. |
3 | Implementation | ArrayList implements only List. | LinkedList implements List as well as Queue. It can acts as a queue as well. |
4 | Access | ArrayList is faster in storing and accessing data. | LinkedList is faster in manipulation of data. |
Example of ArrayList vs LinkedList
JavaTester.java
import java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class JavaTester { public static void main(String args[]) { List<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); List<String> list1 = new LinkedList<>(); list1.add("A"); list1.add("B"); list1.add("C"); list1.add("D"); System.out.println(list); System.out.println(list1); } }
Output
[A, B, C, D] [A, B, C, D]
- Related Articles
- What is the difference between ArrayList and LinkedList in Java?
- Convert LinkedList to ArrayList in Java
- Program to convert ArrayList to LinkedList in Java
- When to use LinkedList over ArrayList in Java
- Difference Between LinkedList and LinkedHashSet in Java
- How to remove an element from ArrayList or, LinkedList in Java?
- Difference between ArrayList and HashSet in Java
- Difference between ArrayList and CopyOnWriteArrayList in Java
- Difference Between List and ArrayList in Java
- Difference between ArrayList and CopyOnWriteArrayList in Java programming.
- Difference between Synchronized ArrayList and CopyOnWriteArrayList in Java
- Differences between & and && operators in Java.
- Differences between | and || operators in Java
- Differences between Java 8 and Java 9?
- Differences between Collection and Collections in Java?

Advertisements