Difference Between ArrayList and LinkedList

Google Advertisements

Prev Tutorial Next Tutorial

Difference Between ArrayList and LinkedList

ArrayList and LinkedList both are implements List interface and maintains insertion order. ArrayList and LinkedList both are non synchronized classes and these are new collection framework classes.

Note: All new Collection Framework are non-Synchronized and all Legacy Collection Framework are Synchronized.

Difference between ArrayList and LinkedList

1ArrayList internally uses dynamic array to store the elements.LinkedList internally uses doubly linked list to store the elements.
2 Manipulation with ArrayList is slow because it internally uses array. If any element is removed from the array, all the bits are shifted in memory.Manipulation with LinkedList is faster than ArrayList because it uses doubly linked list so no bit shifting is required in memory.
3ArrayList class can act as a list only because it implements List only.LinkedList class can act as a list and queue both because it implements List and Deque interfaces.
4ArrayList is better for storing and accessing data.ArrayList is better for storing and accessing data.

Example of ArrayList and LinkedList

import java.util.*;    
class DemoArrayLinked
 public static void main(String args[])
  List<String> al=new ArrayList<String>();  //creating arraylist    
  al.add("Mark");//adding object in arraylist    
  List<String> ll=new LinkedList<String>();  //creating linkedlist    
  ll.add("Smith");  //adding object in linkedlist    
  System.out.println("Arraylist: "+al);  
  System.out.println("Linkedlist: "+ll);  


Arraylist: [Mark, Deo, Pitter, Porter]
Linkedlist: [Smith, Kater, Parker, Holly]

Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on hitesh.xc@gmail.com or 9999595223

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs