0
What is difference between LinkedList and ArrayList
2 ответов
+ 11
ArrayList and LinkedList both implements List interface and maintains insertion order. ... LinkedList internally uses a doubly linked list to store the elements. 2) Manipulation with ArrayList is slow because it internally uses an array. If any element is removed from the array, all the bits are shifted in memory.
+ 4
performance
ArrayList + : get(), set(), "large number of random access of element"
LinkedList+ : remove(), add()
+ "ArrayList is a better choice if your program is thread-safe. "
- "ArrayList grow 50% of its size each time."
(default size is 10, it can be trimmed manually)
"LinkedList adds more methods"
benchmark:
add:
ArrayList 13,265,642
LinkedList 9,550,057
get:
ArrayList 1,543,352
LinkedList 85,085,551
remove
ArrayList 199,961,301
LinkedList 85,768,810
https://dzone.com/articles/arraylist-vs-linkedlist-vs