0
What is the right situation to use ArrayList over LinkedList?
3 odpowiedzi
+ 2
http://stackoverflow.com/questions/322715/when-to-use-linkedlist-over-arraylist
look at the link, it will explain in detail
+ 1
I don't want to read it more than I want to discuss it
0
as far as I understand it, an arraylist does not guarantee an order and utilizes random access. This makes an arraylist fast and inexpensive, but removing an element will cause shifting. in the case of a large arraylist, this can become an expensive operation.
whereas a linked list guarantees that it will keep the order the elements were added in. A linked list can also remove elements from the middle of the list without shifting, as the pointer can simply point to the next or previous object.
A case to linked list over array list: performing multiple remove operations from a large list. Or if you want to keep all elements in the exact order you added them. Otherwise I would suggest using the arraylist.
sorry for any typos or poor wording, I wrote this quickly on my phone.