Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Difference between an ArrayList and a LinkedList in Java?

  1. #1
    Junior Member amodnazirkar's Avatar
    Join Date
    Sep 2021
    Location
    Bangalore
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Difference between an ArrayList and a LinkedList in Java?

    Can someone help me explain the differences between an ArrayList and a LinkedList in Java Programming and their uses?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,145
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Difference between an ArrayList and a LinkedList in Java?

    Start by reading the descriptions for those two classes in the API doc:
    http://docs.oracle.com/javase/8/docs/api/index.html
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2021
    Location
    Pune
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Cool Re: Difference between an ArrayList and a LinkedList in Java?

    Hi,

    I will try answering your query! 🙂

    Arraylist is a class which is a part of the Collections Frameworks in java. It implements the List interface hence all the methods of the List class. The java.util package is required for using this class.

    Syntax

    ArrayList<data_type> name = new ArrayList<data_type>();

    LinkedList are linear data structures similar to arrayLists. The elements are linked using pointers and addresses, Each element is known as a node.

    Let's talk about the differences between ArrayList and LinkedList


    An ArrayList class uses a dynamic array to store the elements in it, Whereas A LinkedList class uses a doubly linked list to store the elements in it.
    Manipulating ArrayList takes more time due to the internal implementation, Whereas Manipulating LinkedList takes less time compared to ArrayList.
    An ArrayList class can act as a list only because it implements List only, Whereas LinkedList class can act as a list and queue both.
    ArrayList is better for storing and accessing data, Whereas LinkedList is better for manipulating data.

    You may refer the following resources for detailed Information:
    https://en.wikipedia.org/wiki/List_of_data_structures
    https://www.scaler.com/topics/arraylist-vs-linkedlist/

  4. #4
    Junior Member
    Join Date
    Oct 2021
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Difference between an ArrayList and a LinkedList in Java?

    Array List and Linked List both are the classes implementing list interface.

    1.Array List and List list both follow insertion order and both allows duplicates and null values.
    2.Array list internally use arrays to store the data and linked list stores the data in the form of nodes.(each node contains data and address of the next node).
    3.initial size of array list is 10 dynamically it increases up to 50 percent, linked list internally uses double linked list to store the data.
    4. For adding and deletion we can go for linked list because in linked list to add and delete data it will not shift elements just it will change the address of the node, but in array list the elements shifting will be done it is bit slow when compared to linked list.
    5. for searching we can go for array list because in linked to search a particular data it will search from head to end up to gets the particular data but in array list it will fetch the data by using get method.
    6. for adding and deletion of data we can use linked list and for searching the data we can go for array list.

Similar Threads

  1. Populating a LinkedList in java
    By pyler in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 18th, 2014, 01:14 PM
  2. Arraylist and LinkedList
    By vilkas123 in forum Collections and Generics
    Replies: 1
    Last Post: November 3rd, 2012, 02:20 AM
  3. Difference between Vector and Arraylist
    By Lil_Aziz1 in forum Collections and Generics
    Replies: 4
    Last Post: January 3rd, 2010, 11:03 AM
  4. Difference between Arraylist and Vector in abstractTableModel ?
    By riddhik84 in forum Collections and Generics
    Replies: 2
    Last Post: November 7th, 2009, 04:22 PM