LinkedList Class

LinkedList Class V/S ArrayList Class

In this blog, we will see how to LinkedList Class and ArrayList collection class different with each other.  Both classes can add data using add() method.

But in this blog, we will also see addFirst() and addLast() method do not working in ArrayList class. We also see how to removeFirst() and removeLast() method do not working in ArrayList class.

This is basic different between ArrayList and LinkedList class.


Let’s see Example on LinkedList Class V/S ArrayList Class


import java.util.*;

class collection5


                public static void main(String args[])


                                ArrayList a1 = new ArrayList();





                                LinkedList a2 = new LinkedList();





                                System.out.println(“ArrayList : ” + a1);

                                System.out.println(“LinkedList : ” + a2);



// ArrayList – Error: We can’t use addFirst And addLast method in ArrayList

                                a2.addFirst(90);                // LinkedList



// ArrayList – Error: We can’t use removeFirst and removeLast method in ArrayList

                                a2.removeFirst();             // LinkedList

                                System.out.println(“ArrayList : ” + a1);

                                System.out.println(“LinkedList : ” + a2);





ArrayList : [56,78,89]

LinkedList : [56,78,89]

—-  Add | Remove Data From Linked List —

ArrayList : [56,78,89]

LinkedList : [56,78,89]

Video on simple LinkedList V/S ArrayList

For more videos on Java visit our YouTube Channel


Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

526total visits,4visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.


Link back if you want.

Enter Captcha Here :*

Reload Image