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

ArrayListLinkedList
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    
  al.add("Deo");
  al.add("Pitter");
  al.add("Porter");
    
  List<String> ll=new LinkedList<String>();  //creating linkedlist    
  ll.add("Smith");  //adding object in linkedlist    
  ll.add("Kater");    
  ll.add("Parker");    
  ll.add("Holly");    
 
  System.out.println("Arraylist: "+al);  
  System.out.println(".........................");  
  System.out.println("Linkedlist: "+ll);  
 }    
}   

Output

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. If you want to post your article on our website/FB Group/FB Page please contact on hitesh.xc@gmail.com or 8076671483

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

Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

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.

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

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android 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