Example & Tutorial understanding programming in easy ways.

When to use ArrayList or LinkedList?


                    ArrayList                         LinkedList
1 Adding new elements is pretty slower than. 1 Adding new elements is pretty fast for either type of list.
2 ArrayList, doing random lookup using "get" is fast. 2 LinkedList, doing random lookup using "get" is slow.
3 The removing elements, using ArrayList is slow. 3 removing elements, using LinkedList is fast.
4 This is because all remaining elements in the underlying array of Object instances must be shifted down for each remove operation. 4 It's slow because there's no efficient way to index into the middle of a linked list.
5 best for cases where you're doing random access on the list. 5 deletion can be done simply by changing a couple of links.
  6 A LinkedList works better if you're doing a lot of editing in the middle of the list.

Read More →