-3

What is the difference between ArrayList and LinkedList? I watched a video on it by TheNewBoston but i am still confused. Please answer in a short form and in plain English. Please do not use any advanced code.

10
  • 1
    The ArrayListed is backed by an array, the LinkedList is a List of double-linked elements. Both implement the java.util.List interface Commented Jul 25, 2014 at 20:04
  • 1
    @scribaniwannabe: It's not exactly a duplicate. It's not the same question being asked. Commented Jul 25, 2014 at 20:04
  • 4
    If the answers on the duplicate question don't make sense then you should say what doesn't make sense Commented Jul 25, 2014 at 20:06
  • 3
    We don't know what you don't know. It's like saying you don't understand the difference between a picture of water and a picture of lemonade, perhaps you just have to try it to see the difference. Commented Jul 25, 2014 at 20:08
  • 2
    @peterzhu2118 If the problem is terminology you don't understand, Wikipedia is your friend. The O(1) etc. notation is commonly called "Big O notation". Commented Jul 25, 2014 at 20:12

2 Answers 2

7

ArrayList is a list implementation that's backed by an Object[]. It supports random access and dynamic resizing.

LinkedList is a list implementation that uses references to head and tail to navigate it. It has no random access capabilities, but it too supports dynamic resizing.

Bear in mind that both support the get(int index) signature, but the difference between the two implementations is performance: with an ArrayList, that's a matter of going to the index position, whereas with a LinkedList, you have to walk down the object chain (either from the front or the rear, depending on what you've indexed into).

Sign up to request clarification or add additional context in comments.

Comments

0

For an arrayList, you have access to every element, which has its own index value. For example, if you want the third item in an ArrayList, you just have to perform arrList.get(2) to get this value. An ArrayList is made using a similar structure as an array.

For a linked list, you ONLY have access to the first element, but each element has access to the next one. So, to get to the third element, you have to go to the first, then second, then finally third. Think of a LinkedList like a chain. If you have the first part of the chain but cut off its access to the second part, you lose the rest of it too.

They both have their advantages and disadvantages, in terms of memory, processing time, and ease of use. Let me know if you have any more specific questions or want clarification.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.