If you have to add or delete the elements at the beginning of a list, should you use ArrayList or LinkedList? And, if most of the operations on a list involve retrieving an element at a given index, should you use ArrayList or LinkedList? Why one over the other?
Asked
Active
Viewed 669 times
1 Answers
0
This sounds like a homework question. In that case, the expected answer is probably a linked list. Adding an element to the beginning of an array list requires moving all other elements. In a link list, you just add a new node at the beginning and that's it.

Malt
- 28,965
- 9
- 65
- 105