-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.

tckmn
  • 57,719
  • 27
  • 114
  • 156
Peter Zhu
  • 421
  • 6
  • 16
  • 1
    The ArrayListed is backed by an array, the LinkedList is a List of double-linked elements. Both implement the java.util.List interface – mschenk74 Jul 25 '14 at 20:04
  • As you say, my master! – Heisenberg Jul 25 '14 at 20:04
  • 1
    @scribaniwannabe: It's not *exactly* a duplicate. It's not the same question being asked. – Makoto Jul 25 '14 at 20:04
  • 4
    If the answers on the duplicate question don't make sense then you should say _what_ doesn't make sense – BitNinja Jul 25 '14 at 20:06
  • 1
    The accepted, and extremely highly upvoted, answer to the question @scribaniwannabe references is also a good answer to this question. It may be best to wait until you can post comments, and add a comment to that answer asking specific questions. – Patricia Shanahan Jul 25 '14 at 20:07
  • @BitNinja There is too much advanced terminology in it – Peter Zhu Jul 25 '14 at 20:08
  • 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. – Peter Lawrey Jul 25 '14 at 20:08
  • Every one has the start somewhere, but if you have twenty plus years programming experience it will seems really, really simple. Perhaps it seems hard because you believe it is hard, perhaps you assume there is more difference than there really is. – Peter Lawrey Jul 25 '14 at 20:10
  • [List of data structures](http://en.wikipedia.org/wiki/List_of_data_structures) – rodrigoap Jul 25 '14 at 20:11
  • 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"](http://en.wikipedia.org/wiki/Big_O_notation). – Patricia Shanahan Jul 25 '14 at 20:12

2 Answers2

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).

Makoto
  • 104,088
  • 27
  • 192
  • 230
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.

StoneMan
  • 423
  • 3
  • 18